From: Matt Joiner Date: Tue, 12 Oct 2021 00:58:46 +0000 (+1100) Subject: Some fixes to pending request accounting X-Git-Tag: v1.34.0^2~43 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5f31bd83b337c671a298bf72d4be1d1997c55da7;p=btrtrc.git Some fixes to pending request accounting --- diff --git a/peerconn.go b/peerconn.go index e00006ff..e683be5c 100644 --- a/peerconn.go +++ b/peerconn.go @@ -1035,7 +1035,9 @@ func (c *PeerConn) mainReadLoop() (err error) { } switch msg.Type { case pp.Choke: - c.peerChoking = true + if c.peerChoking { + break + } if !c.fastEnabled() { c.deleteAllRequests() } else { @@ -1046,6 +1048,7 @@ func (c *PeerConn) mainReadLoop() (err error) { return true }) } + c.peerChoking = true // We can then reset our interest. c.updateRequests("choked") c.updateExpectingChunks() @@ -1132,7 +1135,7 @@ func (c *PeerConn) mainReadLoop() (err error) { if r >= t.pieceRequestIndexOffset(pieceIndex+1) { break } - c.t.pendingRequests.Inc(i.Next()) + c.t.pendingRequests.Inc(r) } } c.updateRequests("PeerConn.mainReadLoop allowed fast")