]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Lower webseed read chunks log level when peer is closed
authorMatt Joiner <anacrolix@gmail.com>
Wed, 6 Aug 2025 12:56:36 +0000 (22:56 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 6 Aug 2025 12:56:36 +0000 (22:56 +1000)
webseed-peer.go

index b1ff7dd4446c5bf91276cf22ccc0813c6d380f0a..cf3a9e0109b1f6f2e84fa6ce6687b45ea875ee53 100644 (file)
@@ -173,10 +173,13 @@ func (me *webseedPeer) hasOverlappingRequests(begin, end RequestIndex) bool {
        return false
 }
 
-func readChunksErrorLevel(err error, req *webseedRequest) slog.Level {
+func (ws *webseedPeer) readChunksErrorLevel(err error, req *webseedRequest) slog.Level {
        if req.cancelled.Load() {
                return slog.LevelDebug
        }
+       if ws.peer.closedCtx.Err() != nil {
+               return slog.LevelDebug
+       }
        var h2e http2.GoAwayError
        if errors.As(err, &h2e) {
                if h2e.ErrCode == http2.ErrCodeEnhanceYourCalm {
@@ -200,7 +203,7 @@ func (ws *webseedPeer) runRequest(webseedRequest *webseedRequest) {
        // Ensure the body reader and response are closed.
        webseedRequest.Close()
        if err != nil {
-               level := readChunksErrorLevel(err, webseedRequest)
+               level := ws.readChunksErrorLevel(err, webseedRequest)
                ws.slogger().Log(context.TODO(), level, "webseed request error", "err", err)
                torrent.Add("webseed request error count", 1)
                // This used to occur only on webseed.ErrTooFast but I think it makes sense to slow down any