cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

The examples and cmd race #34

Closed danmux closed 6 years ago

danmux commented 6 years ago

selecting on a ticker channel and accessing the resp object whilst the client Do method is working on it causes a race.

Easily reproduced.

The race exists between setting up the transfer and reading anything from it. As client.Do returns before resp.transfer has been fully set up, it can be read from 'too soon'.

In fact calling go resp.watchBps() also races with the transfer assignment.

(I will tal at a solution soon)

danmux commented 6 years ago

OK I can see this is only an issue in v2.0.0 master has it fixed by moving the transfer setup 👍

cavaliercoder commented 6 years ago

Thanks for reporting! I've updated the v2 tag now to cover this fix.