From 5301ec0ffb8e51caea0c5385dd4c7da138fa748e Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Thu, 1 Aug 2024 18:04:40 -0700 Subject: [PATCH] udpmux: Don't log an error if canceled because of shutdown --- p2p/transport/webrtc/udpmux/mux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p2p/transport/webrtc/udpmux/mux.go b/p2p/transport/webrtc/udpmux/mux.go index 1ce490988f..85392c5d56 100644 --- a/p2p/transport/webrtc/udpmux/mux.go +++ b/p2p/transport/webrtc/udpmux/mux.go @@ -5,6 +5,7 @@ package udpmux import ( "bytes" "context" + "errors" "fmt" "io" "net" @@ -143,7 +144,7 @@ func (mux *UDPMux) readLoop() { n, addr, err := mux.socket.ReadFrom(buf) if err != nil { - if strings.Contains(err.Error(), "use of closed network connection") { + if strings.Contains(err.Error(), "use of closed network connection") || errors.Is(err, context.Canceled) { log.Debugf("readLoop exiting: socket %s closed", mux.socket.LocalAddr()) } else { log.Errorf("error reading from socket %s: %v", mux.socket.LocalAddr(), err)