]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Do webseed request updates asynchronously
authorMatt Joiner <anacrolix@gmail.com>
Mon, 6 Dec 2021 08:24:04 +0000 (19:24 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 12 Dec 2021 05:56:01 +0000 (16:56 +1100)
Fixes a bug where received chunks are immediately requested while still being processed.

webseed-peer.go

index cfce1e81d4b2768b9264340f28586c21b6ce2c7d..85e121194d28c22c6d3180a6d8a45cd79d7a1c80 100644 (file)
@@ -124,7 +124,11 @@ func (ws *webseedPeer) drop() {}
 func (ws *webseedPeer) handleUpdateRequests() {
        // Because this is synchronous, webseed peers seem to get first dibs on newly prioritized
        // pieces.
-       ws.peer.maybeUpdateActualRequestState()
+       go func() {
+               ws.peer.t.cl.lock()
+               defer ws.peer.t.cl.unlock()
+               ws.peer.maybeUpdateActualRequestState()
+       }()
 }
 
 func (ws *webseedPeer) onClose() {