This commit is contained in:
suyl
2021-10-19 18:19:58 +08:00
parent 175b81d0fd
commit aa2a2d4668
2 changed files with 11 additions and 3 deletions

View File

@@ -259,15 +259,21 @@ func (t *TcpClient) setPrintStatusTime(key string) {
}
}
func (t *TcpClient) addMsgChan(printMsg *model.PrintMsg) {
func (t *TcpClient) addMsgChan(printMsg *model.PrintMsg) (err error) {
t.Lock()
defer t.Unlock()
defer func() {
t.Unlock()
if r := recover(); r != nil && r.(error).Error() == "send on closed channel" {
err = fmt.Errorf("send on closed channel")
}
}()
if t.MsgMap[printMsg.PrintNo] == nil {
dataChan := make(chan *model.PrintMsg, 1024)
t.MsgMap[printMsg.PrintNo] = dataChan
}
globals.SugarLogger.Debugf("addMsgChan msgID: %s", printMsg.MsgID)
t.MsgMap[printMsg.PrintNo] <- printMsg
return err
}
func (t *TcpClient) addCallbackChan(key, data string) {