1
0
mirror of https://github.com/veggiedefender/torrent-client.git synced 2025-11-06 09:29:16 +02:00

Fix race condition

The download loop might finish and kill the worker goroutine before it's
done sending HAVE messages. Switching the order of these two lines
trivially fixes the issue (but it's still brittle)
This commit is contained in:
Jesse Li
2020-01-02 10:41:21 -05:00
parent 73a9a5216b
commit 70713e028d

View File

@@ -173,8 +173,8 @@ func (t *Torrent) startDownloadWorker(peer peers.Peer, workQueue chan *pieceWork
continue
}
results <- &pieceResult{pw.index, buf}
c.have(pw.index)
results <- &pieceResult{pw.index, buf}
}
}