This commit is contained in:
suyl
2021-08-03 14:52:08 +08:00
parent aeee9731cd
commit 9b8bc1c240

View File

@@ -191,6 +191,8 @@ func (t *TcpClient) doPrint(key string) (err error) {
if !t.isExistMsg(key) { if !t.isExistMsg(key) {
return err return err
} }
defer close(t.MsgMap[key])
defer close(t.CallBackMap[key])
globals.SugarLogger.Debugf("doPrint printNo: %s", key) globals.SugarLogger.Debugf("doPrint printNo: %s", key)
go func() { go func() {
for { for {
@@ -201,7 +203,7 @@ func (t *TcpClient) doPrint(key string) (err error) {
default: default:
select { select {
case printMsg, ok := <-t.MsgMap[key]: case printMsg, ok := <-t.MsgMap[key]:
if !ok{ if !ok {
return return
} }
var ( var (
@@ -254,14 +256,13 @@ func (t *TcpClient) doPrint(key string) (err error) {
} }
} }
}() }()
close(t.MsgMap[key])
close(t.CallBackMap[key])
return err return err
} }
//检测心跳 //检测心跳
func (t *TcpClient) HandleCheckTcpHeart(key string) { func (t *TcpClient) HandleCheckTcpHeart(key string) {
globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key) globals.SugarLogger.Debugf("HandleCheckTcpHeart begin key: %s", key)
defer t.Clients[key].C.Close()
go func() { go func() {
for { for {
select { select {
@@ -297,5 +298,4 @@ func (t *TcpClient) HandleCheckTcpHeart(key string) {
//} //}
} }
}() }()
t.Clients[key].C.Close()
} }