aceld / aceld/zinx

SendBuffMsg存在安全问题.

Đang mở
#71 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
7.8k
Fork
1.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

c.msgBuffChan <- msg
//在大并发高负载的情况下 经常因为这句崩溃,原因是向一个关闭的chan写入数据,
//可能是在“将data封包,并且发送”的时候chan被其他携程关闭了 所有在发送前最后再检查一下最好!

func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error {
if c.isClosed == true {
return errors.New("Connection closed when send buff msg")
}
//将data封包,并且发送
dp := NewDataPack()
msg, err := dp.Pack(NewMsgPackage(msgId, data))
if err != nil {
fmt.Println("Pack error msg id = ", msgId)
return errors.New("Pack error msg ")
}

//写回客户端
c.msgBuffChan <- msg

return nil
}

错误日志:

---> CallOnConnStart....
[Writer Goroutine is running]
[Reader Goroutine is running]
read msg head error EOF
Conn Stop()...ConnID = 156
---> CallOnConnStop....
Send Buff Data error:, write tcp4 172.21.0.15:7777->39.189.45.248:14870: use of closed network connection Conn Writer exit
39.189.45.248:14870 [conn Writer exit!]
connection Remove ConnID= 156 successfully: conn num = 0
39.189.45.248:14870 [conn Reader exit!]
panic: send on closed channel

goroutine 36 [running]:
github.com/aceld/zinx/znet.(*Connection).SendBuffMsg(0xc0000d00e0, 0x1f4, 0xc0003f9400, 0x95, 0xa0, 0x0, 0x0)
/Users/jamie/go/pkg/mod/github.com/aceld/zinx@v0.0.0-20200315073925-f09df55dc746/znet/connection.go:226 +0x1ec
YmServer/tools.Response(0xac40c0, 0xc000524a20, 0x1000001f4, 0x9fc41e, 0x2, 0xc000515470)
/Users/jamie/go/src/YmServer/tools/toos.go:35 +0x10d
YmServer/controller.(*GetMyGameProxyRouter).Handle(0xe84c88, 0xac40c0, 0xc000524a20)
/Users/jamie/go/src/YmServer/controller/my_game.go:72 +0x517
github.com/aceld/zinx/znet.(*MsgHandle).DoMsgHandler(0xc000217080, 0xac40c0, 0xc000524a20)
/Users/jamie/go/pkg/mod/github.com/aceld/zinx@v0.0.0-20200315073925-f09df55dc746/znet/msghandler.go:47 +0xe4
github.com/aceld/zinx/znet.(*MsgHandle).StartOneWorker(0xc000217080, 0x6, 0xc000234720)
/Users/jamie/go/pkg/mod/github.com/aceld/zinx@v0.0.0-20200315073925-f09df55dc746/znet/msghandler.go:70 +0x103
created by github.com/aceld/zinx/znet.(*MsgHandle).StartWorkerPool
/Users/jamie/go/pkg/mod/github.com/aceld/zinx@v0.0.0-20200315073925-f09df55dc746/znet/msghandler.go:83 +0x50

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.