From d99a6fcb7ccd48831eb8b8fccebfded6ced1d2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Thu, 8 Dec 2022 21:18:58 +0100 Subject: [PATCH] Return ErrClosedPipe for writeTo Return ErrClosedPipe for writeTo --- candidate_base.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/candidate_base.go b/candidate_base.go index 289a0f4..3fb60f3 100644 --- a/candidate_base.go +++ b/candidate_base.go @@ -308,6 +308,10 @@ func (c *candidateBase) close() error { func (c *candidateBase) writeTo(raw []byte, dst Candidate) (int, error) { n, err := c.conn.WriteTo(raw, dst.addr()) if err != nil { + // If the connection is closed, we should return the error + if errors.Is(err, io.ErrClosedPipe) { + return n, err + } c.agent().log.Infof("%s: %v", errSendPacket, err) return n, nil }