浏览代码

fix: conn nil

lijian 2 年之前
父节点
当前提交
5b798d96b3
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      pkg/mqtt/connection.go

+ 3 - 3
pkg/mqtt/connection.go

@@ -317,15 +317,15 @@ func (c *Connection) RcvMsgFromClient() {
 func (c *Connection) SendMsgToClient() {
 	c.mLock.Lock()
 	c.mLock.Unlock()
-	if c.Conn == nil {
-		return
-	}
 	host := c.Conn.RemoteAddr()
 	for {
 		select {
 		case <-c.closeChan:
 			return
 		case msg, ok := <-c.SendChan:
+			if c.Conn == nil {
+				return
+			}
 			if !ok {
 				server.Log.Errorf("%s is end now", host)
 				return