From 9dbb64073a94ed0c7b607a794690beb3f11a590b Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Fri, 30 Jul 2021 18:24:53 +0800 Subject: [PATCH] a --- business/jxstore/event/event_tcp.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/business/jxstore/event/event_tcp.go b/business/jxstore/event/event_tcp.go index 07f88955a..4becccc6d 100644 --- a/business/jxstore/event/event_tcp.go +++ b/business/jxstore/event/event_tcp.go @@ -76,6 +76,7 @@ func (t *TcpClient) handleConn(c net.Conn) { globals.SugarLogger.Debugf("handleConn printno :[%v]", printNo) status := printStatus2JxStatus(data[len(data)-8 : len(data)-6]) if t.Clients[printNo] == nil { + timeoutChan <- 1 t.addConn(c, printNo, status) t.HandleTcpMessages(printNo) t.doPrint(printNo) @@ -146,17 +147,17 @@ func (t *TcpClient) HandleTcpMessages(printNo string) { offset, pageSize = 0, 1 ) globals.SugarLogger.Debugf("build HandleTcpMessages printNo: %s", printNo) - go func(key string) { + go func() { for { //一直读? - prints, _ := dao.GetPrintMsgs(db, key, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize) + prints, _ := dao.GetPrintMsgs(db, printNo, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize) for _, printMsg := range prints { t.addMsgChan(printMsg) printMsg.Status = printMsgAlreadyLoad dao.UpdateEntity(db, printMsg, "Status") } } - }(printNo) + }() } func (t *TcpClient) doPrint(key string) (err error) { @@ -167,10 +168,10 @@ func (t *TcpClient) doPrint(key string) (err error) { if !t.isExistMsg(key) { return err } - go func(key string) { + go func(printNo string) { for { select { - case printMsg := <-t.MsgMap[key]: + case printMsg := <-t.MsgMap[printNo]: var ( data []byte c net.Conn @@ -213,6 +214,7 @@ func (t *TcpClient) doPrint(key string) (err error) { } } } + case <-timeoutChan: } } }(key)