From: Matt Joiner Date: Mon, 6 Dec 2021 08:24:04 +0000 (+1100) Subject: Do webseed request updates asynchronously X-Git-Tag: v1.39.0~4 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ad082bc6444edf5e9d2cee38a906a8e2e84392a4;p=btrtrc.git Do webseed request updates asynchronously Fixes a bug where received chunks are immediately requested while still being processed. --- diff --git a/webseed-peer.go b/webseed-peer.go index cfce1e81..85e12119 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -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() {