Don't delete requests until after they're written to disk
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.
This commit is contained in:
parent
fc039262d9
commit
c28e9aaeae
16
peerconn.go
16
peerconn.go
|
@ -1289,14 +1289,16 @@ func (c *peer) receiveChunk(msg *pp.Message) error {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue