This prevents too many pending writes building up. Webseed peers re-request synchronously, and the writes are done asynchronously, so they download too quickly and there was no backpressure. The backpressure now is provided by the upper limit on outstanding requests per connection.
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) {