Browse Source

修复两个sendbuf方法中可能导致的panic和go程泄露问题

master
gufeijun 4 years ago
parent
commit
889df45920
  1. 7
      znet/connection.go

7
znet/connection.go

@ -206,11 +206,11 @@ func (c *Connection) RemoteAddr() net.Addr {
//直接将Message数据发送数据给远程的TCP客户端
func (c *Connection) SendMsg(msgId uint32, data []byte) error {
c.RLock()
defer c.RUnlock()
if c.isClosed == true {
c.RUnlock()
return errors.New("connection closed when send msg")
}
c.RUnlock()
//将data封包,并且发送
dp := NewDataPack()
@ -228,11 +228,10 @@ func (c *Connection) SendMsg(msgId uint32, data []byte) error {
func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error {
c.RLock()
defer c.RUnlock()
if c.isClosed == true {
c.RUnlock()
return errors.New("Connection closed when send buff msg")
}
c.RUnlock()
//将data封包,并且发送
dp := NewDataPack()

Loading…
Cancel
Save