From aa1f9dfa5c70bb170bedd5651d2af9b87758ac3c Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Tue, 12 Nov 2024 19:23:02 -0600 Subject: [PATCH] fix(idleconn): Ensure cancel func is not nill before calling it --- internal/server/idleconn/conn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/server/idleconn/conn.go b/internal/server/idleconn/conn.go index 19fa9425..62d848c2 100644 --- a/internal/server/idleconn/conn.go +++ b/internal/server/idleconn/conn.go @@ -28,7 +28,7 @@ func (c *Conn) Write(p []byte) (int, error) { _ = c.updateDeadline() n, err := c.Conn.Write(p) - if errors.Is(err, os.ErrDeadlineExceeded) { + if c.cancel != nil && errors.Is(err, os.ErrDeadlineExceeded) { c.cancel() } return n, err @@ -38,7 +38,7 @@ func (c *Conn) Read(b []byte) (int, error) { _ = c.updateDeadline() n, err := c.Conn.Read(b) - if errors.Is(err, os.ErrDeadlineExceeded) { + if c.cancel != nil && errors.Is(err, os.ErrDeadlineExceeded) { c.cancel() } return n, err