Skip to content

Commit fbd7000

Browse files
authored
Merge pull request #330 from yunxi177/master
connection isClose 方法判断,防止 c.ctx 不存在导致程序 panic
2 parents 7a3b9bd + 1fc2a92 commit fbd7000

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

znet/connection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,10 @@ func (c *Connection) GetMsgHandler() ziface.IMsgHandle {
544544
}
545545

546546
func (c *Connection) isClosed() bool {
547-
return c.ctx.Err() != nil
547+
return c.ctx == nil || c.ctx.Err() != nil
548548
}
549549

550+
550551
func (c *Connection) setStartWriterFlag() bool {
551552
return atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1)
552553
}

0 commit comments

Comments
 (0)