]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Reorder spawn requests conditions
authorMatt Joiner <anacrolix@gmail.com>
Fri, 23 May 2025 04:41:12 +0000 (14:41 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 23 May 2025 04:41:12 +0000 (14:41 +1000)
Should just be faster

webseed-peer.go

index 89e7bf6cdf6c8cdfeaa29b04670478c11c18185f..ae91a91fc0dc0a2591adfcf1963f363619aca760 100644 (file)
@@ -183,14 +183,14 @@ func (ws *webseedPeer) spawnRequests() {
        next, stop := iter.Pull(ws.inactiveRequests())
        defer stop()
        for {
-               if len(ws.activeRequests) >= ws.client.MaxRequests {
+               if !ws.peer.t.cl.underWebSeedHttpRequestLimit() {
                        break
                }
-               req, ok := next()
-               if !ok {
+               if ws.numRequests() >= ws.client.MaxRequests {
                        break
                }
-               if !ws.peer.t.cl.underWebSeedHttpRequestLimit() {
+               req, ok := next()
+               if !ok {
                        break
                }
                end := seqLast(ws.iterConsecutiveInactiveRequests(req)).Unwrap()