peerconn.go | 16 +++++++++------- diff --git a/peerconn.go b/peerconn.go index 60d004650028e50b3ec6b4f85076a0cfad40a2a2..9ad056ce6658c2ed89b1a59ed0d6b46edd5d93a7 100644 --- a/peerconn.go +++ b/peerconn.go @@ -1289,14 +1289,16 @@ if c.peerChoking && c.peerAllowedFast.Get(int(req.Index)) { torrent.Add("chunks received due to allowed fast", 1) } - // Request has been satisfied. - if c.deleteRequest(req) { - if c.expectingChunks() { - c._chunksReceivedWhileExpecting++ + defer func() { + // Request has been satisfied. + if c.deleteRequest(req) { + if c.expectingChunks() { + c._chunksReceivedWhileExpecting++ + } + } else { + torrent.Add("chunks received unwanted", 1) } - } else { - torrent.Add("chunks received unwanted", 1) - } + }() // Do we actually want this chunk? if t.haveChunk(req) {