]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Panic if pending request count goes negative in requesting
authorMatt Joiner <anacrolix@gmail.com>
Tue, 12 Oct 2021 02:06:59 +0000 (13:06 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 19 Oct 2021 03:08:56 +0000 (14:08 +1100)
requesting.go

index d43114138ed4f081e2384df82b8330d0991402ff..c1575885d281605823bceba42eb584578b62b396 100644 (file)
@@ -144,6 +144,12 @@ func (p *peerRequests) Less(i, j int) bool {
                if current {
                        ret--
                }
+               // I have a hunch that this could trigger for requests for chunks that are choked and not
+               // allowed fast, since the current conn shouldn't already be included. It's a very specific
+               // circumstance, and if it triggers I will fix it.
+               if ret < 0 {
+                       panic(ret)
+               }
                return ret
        }
        ml := multiless.New()