]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Coalesce synchronous webseed request updates
authorMatt Joiner <anacrolix@gmail.com>
Sat, 19 Jul 2025 11:45:58 +0000 (21:45 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 19 Jul 2025 11:45:58 +0000 (21:45 +1000)
webseed-requesting.go

index 05f5963649ef7699fa73a9fac12c232aa0ea835d..71a1ec7079de481c285eac68c65b9d63b4d3bed6 100644 (file)
@@ -348,8 +348,10 @@ func (cl *Client) scheduleImmediateWebseedRequestUpdate() {
                // Timer function already running, let it do its thing.
                return
        }
-       // Handle the update right now.
-       cl.updateWebseedRequestsAndResetTimer()
+       // Set the timer to fire right away (this will coalesce consecutive updates without forcing an
+       // update on every call to this method). Since we're holding the Client lock, and we cancelled
+       // the timer and it wasn't active, nobody else should have reset it before us.
+       panicif.True(cl.webseedRequestTimer.Reset(0))
 }
 
 func (cl *Client) updateWebseedRequestsTimerFunc() {