aa
This commit is contained in:
@@ -199,8 +199,9 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
globals.SugarLogger.Debugf("doPrint timeout")
|
||||
return
|
||||
default:
|
||||
printMsg, ok := <-t.MsgMap[key]
|
||||
if !ok {
|
||||
select {
|
||||
case printMsg, ok := <-t.MsgMap[key]:
|
||||
if !ok{
|
||||
return
|
||||
}
|
||||
var (
|
||||
@@ -230,19 +231,15 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
printMsg.Status = printMsgErr
|
||||
printMsg.Comment = err.Error()
|
||||
dao.UpdateEntity(db, printMsg, "Status", "Comment")
|
||||
if t.isExist(key) {
|
||||
t.clear(key)
|
||||
close(t.TimeoutMap[key])
|
||||
globals.SugarLogger.Debugf("handleTcpMessages clear1...")
|
||||
}
|
||||
} else {
|
||||
if c != nil {
|
||||
if _, err = c.Write(data); err != nil {
|
||||
globals.SugarLogger.Debugf("handleTcpMessages err [%v]", err)
|
||||
//t.delConn(printMsg.PrintNo)
|
||||
if t.isExist(key) {
|
||||
t.clear(key)
|
||||
close(t.TimeoutMap[key])
|
||||
globals.SugarLogger.Debugf("handleTcpMessages clear2...")
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
||||
//等待回调
|
||||
@@ -255,7 +252,10 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
close(t.MsgMap[key])
|
||||
close(t.CallBackMap[key])
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -273,14 +273,12 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
//2分钟内没心跳判断打印机掉线了
|
||||
if time.Now().Sub(t.getPrintStatusTime(key)) > time.Minute+time.Second*3 {
|
||||
changePrinterStatus(key, printerStatusOffline)
|
||||
if t.isExist(key) {
|
||||
globals.SugarLogger.Debugf("HandleCheckTcpHeart clear...")
|
||||
//t.clear(key)
|
||||
close(t.TimeoutMap[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//keys := []string{}
|
||||
//t.RLock()
|
||||
//for k, v := range t.Clients {
|
||||
@@ -299,4 +297,5 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
|
||||
//}
|
||||
}
|
||||
}()
|
||||
t.Clients[key].C.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user