From 4f934b5bf05216c25c6dfbafe1ffedeacd796352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 16 Mar 2023 11:00:29 +0800 Subject: [PATCH] 1 --- business/jxstore/event/event_tcp.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index e59ad8afd..084a98001 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -79,6 +79,7 @@ func (t *TcpClient) handleConn(c net.Conn) error { if strings.Contains(data, heartText) || strings.Contains(data, heartTextNew) { printNoData, _ := hex.DecodeString(data[len(heartText) : len(data)-8]) printNo = string(printNoData) + globals.SugarLogger.Debugf("TimeoutMap 1:%s", utils.Format4Output(t.TimeoutMap[printNo], false)) status := printStatus2JxStatus(data[len(data)-8 : len(data)-6]) //如果没在连接池里 //1、加到连接池中,不同的打印机no开不同的goroutine @@ -91,6 +92,7 @@ func (t *TcpClient) handleConn(c net.Conn) error { t.addConn(c, printNo, status) t.buildAllMap(printNo) t.HandleTcpMessages(printNo) + globals.SugarLogger.Debugf("TimeoutMap 3:%s", utils.Format4Output(t.TimeoutMap[printNo], false)) t.doPrint(printNo) if status == printerStatusOnline { //t.printFail() @@ -315,7 +317,7 @@ func (t *TcpClient) doPrint(key string) (err error) { //检测心跳 func (t *TcpClient) HandleCheckTcpHeart(key string) { - globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key) + globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %v", <-t.TimeoutMap[key]) go func() { for { select { @@ -324,6 +326,7 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) { close(t.MsgMap[key]) close(t.CallBackMap[key]) t.delConn(key) + close(t.TimeoutMap[key]) //delete(t.Clients, key) return default: @@ -332,8 +335,8 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) { //1分钟内没心跳判断打印机掉线了 if time.Now().Sub(statusTime) > time.Minute+time.Second*10 { changePrinterStatus(key, printerStatusOffline) - //t.clear(key) close(t.TimeoutMap[key]) + t.clear(key) } } }