From 7591db5109b77bac4e56a458e45086e52bd8153e Mon Sep 17 00:00:00 2001 From: Rim Zaydullin Date: Fri, 30 Aug 2024 01:06:59 +0800 Subject: [PATCH] Close net connection first, to release blocked reader, then all pending ops on that connection will be properly released. --- conn.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conn.go b/conn.go index 6adb94618e..2d2a81f9cc 100644 --- a/conn.go +++ b/conn.go @@ -210,16 +210,16 @@ func (c *connect) close() error { c.closed = true c.mutexClose.Unlock() + if err := c.conn.Close(); err != nil { + return err + } + c.buffer = nil c.mutex.Lock() c.reader = nil c.mutex.Unlock() - if err := c.conn.Close(); err != nil { - return err - } - return nil }