Skip to content

Commit

Permalink
fix(idleconn): Ensure cancel func is not nill before calling it
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Nov 13, 2024
1 parent 9e93ac0 commit aa1f9df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/server/idleconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit aa1f9df

Please sign in to comment.