Skip to content

Commit

Permalink
Merge pull request #330 from yunxi177/master
Browse files Browse the repository at this point in the history
connection isClose 方法判断,防止 c.ctx 不存在导致程序 panic
  • Loading branch information
aceld authored Jul 12, 2024
2 parents 7a3b9bd + 1fc2a92 commit fbd7000
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 fbd7000

Please sign in to comment.