]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Reintroduce 64 outbound request cap
authorMatt Joiner <anacrolix@gmail.com>
Mon, 8 Feb 2016 05:09:12 +0000 (16:09 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 8 Feb 2016 05:09:12 +0000 (16:09 +1100)
connection.go

index 2340e5e245b9d797fb1a8938b0fd412a2db17079..a3e6041ad3d031588e9f48c2e6a2dcd012d3f704 100644 (file)
@@ -299,9 +299,18 @@ func (c *connection) requestedMetadataPiece(index int) bool {
        return index < len(c.metadataRequests) && c.metadataRequests[index]
 }
 
+// The actual value to use as the maximum outbound requests.
+func (c *connection) nominalMaxRequests() (ret int) {
+       ret = c.PeerMaxRequests
+       if ret > 64 {
+               ret = 64
+       }
+       return
+}
+
 // Returns true if more requests can be sent.
 func (c *connection) Request(chunk request) bool {
-       if len(c.Requests) >= c.PeerMaxRequests {
+       if len(c.Requests) >= c.nominalMaxRequests() {
                return false
        }
        if !c.PeerHasPiece(int(chunk.Index)) {