diff --git a/znet/connection.go b/znet/connection.go index 25b04927..29521c88 100644 --- a/znet/connection.go +++ b/znet/connection.go @@ -544,9 +544,10 @@ func (c *Connection) GetMsgHandler() ziface.IMsgHandle { } func (c *Connection) isClosed() bool { - return c.ctx.Err() != nil + return c.ctx == nil || c.ctx.Err() != nil } + func (c *Connection) setStartWriterFlag() bool { return atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1) }