Skip to content

Commit

Permalink
Merge pull request #286 from xiongyuhmba/master
Browse files Browse the repository at this point in the history
解决connection模块写时,出现往空的channel写的panic错误
  • Loading branch information
aceld authored Nov 24, 2023
2 parents 7ab8f15 + 459e417 commit 4951f22
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions znet/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,6 @@ func (c *Connection) finalizer() {
c.connManager.Remove(c)
}

// Close all channels associated with the connection
if c.msgBuffChan != nil {
close(c.msgBuffChan)
}

zlog.Ins().InfoF("Conn Stop()...ConnID = %d", c.connID)
}

Expand Down Expand Up @@ -568,15 +563,9 @@ func (c *Connection) isClosed() bool {
}

func (c *Connection) setClose() bool {
if atomic.CompareAndSwapInt32(&c.closed, 0, 1) {
return true
}
return false
return atomic.CompareAndSwapInt32(&c.closed, 0, 1)
}

func (c *Connection) setStartWriterFlag() bool {
if atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1) {
return true
}
return false
return atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1)
}

0 comments on commit 4951f22

Please sign in to comment.