Skip to content

Commit 4951f22

Browse files
authored
Merge pull request #286 from xiongyuhmba/master
解决connection模块写时,出现往空的channel写的panic错误
2 parents 7ab8f15 + 459e417 commit 4951f22

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

znet/connection.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,6 @@ func (c *Connection) finalizer() {
507507
c.connManager.Remove(c)
508508
}
509509

510-
// Close all channels associated with the connection
511-
if c.msgBuffChan != nil {
512-
close(c.msgBuffChan)
513-
}
514-
515510
zlog.Ins().InfoF("Conn Stop()...ConnID = %d", c.connID)
516511
}
517512

@@ -568,15 +563,9 @@ func (c *Connection) isClosed() bool {
568563
}
569564

570565
func (c *Connection) setClose() bool {
571-
if atomic.CompareAndSwapInt32(&c.closed, 0, 1) {
572-
return true
573-
}
574-
return false
566+
return atomic.CompareAndSwapInt32(&c.closed, 0, 1)
575567
}
576568

577569
func (c *Connection) setStartWriterFlag() bool {
578-
if atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1) {
579-
return true
580-
}
581-
return false
570+
return atomic.CompareAndSwapInt32(&c.startWriterFlag, 0, 1)
582571
}

0 commit comments

Comments
 (0)