From fd3a0a3d4402ad1afafbf3f3a5d7eae750ba700b Mon Sep 17 00:00:00 2001 From: liudanbing Date: Thu, 25 Apr 2024 11:25:50 +0800 Subject: [PATCH] fix close channel Write goroutins --- znet/connection.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/znet/connection.go b/znet/connection.go index 2a992c67..c651b186 100644 --- a/znet/connection.go +++ b/znet/connection.go @@ -389,13 +389,10 @@ func (c *Connection) SendToQueue(data []byte) error { select { case <-c.ctx.Done(): return errors.New("connection closed when send buff msg") - default: - select { - case <-idleTimeout.C: - return errors.New("send buff msg timeout") - case c.msgBuffChan <- data: - return nil - } + case <-idleTimeout.C: + return errors.New("send buff msg timeout") + case c.msgBuffChan <- data: + return nil } }