2
0
mirror of synced 2025-02-23 22:28:11 +00:00

Some fixes to pending request accounting

This commit is contained in:
Matt Joiner 2021-10-12 11:58:46 +11:00
parent b2cabe7dbf
commit 5f31bd83b3

View File

@ -1035,7 +1035,9 @@ func (c *PeerConn) mainReadLoop() (err error) {
} }
switch msg.Type { switch msg.Type {
case pp.Choke: case pp.Choke:
c.peerChoking = true if c.peerChoking {
break
}
if !c.fastEnabled() { if !c.fastEnabled() {
c.deleteAllRequests() c.deleteAllRequests()
} else { } else {
@ -1046,6 +1048,7 @@ func (c *PeerConn) mainReadLoop() (err error) {
return true return true
}) })
} }
c.peerChoking = true
// We can then reset our interest. // We can then reset our interest.
c.updateRequests("choked") c.updateRequests("choked")
c.updateExpectingChunks() c.updateExpectingChunks()
@ -1132,7 +1135,7 @@ func (c *PeerConn) mainReadLoop() (err error) {
if r >= t.pieceRequestIndexOffset(pieceIndex+1) { if r >= t.pieceRequestIndexOffset(pieceIndex+1) {
break break
} }
c.t.pendingRequests.Inc(i.Next()) c.t.pendingRequests.Inc(r)
} }
} }
c.updateRequests("PeerConn.mainReadLoop allowed fast") c.updateRequests("PeerConn.mainReadLoop allowed fast")