Skip to content

Commit

Permalink
connection isClose 方法判断,防止 c.ctx 不存在导致程序 panic
Browse files Browse the repository at this point in the history
connection isClose 方法判断,防止 c.ctx 不存在导致程序 panic
  • Loading branch information
yunxi177 authored Jul 12, 2024
1 parent 7a3b9bd commit 1fc2a92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion znet/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1fc2a92

Please sign in to comment.