This commit is contained in:
邹宗楠
2025-02-06 14:23:34 +08:00
parent 810eefd386
commit d70f73b541
2 changed files with 15 additions and 106 deletions

View File

@@ -149,11 +149,25 @@ func (t *TcpClient) delConn(key string) {
t.Lock()
defer t.Unlock()
if t.Clients[key].C != nil {
globals.SugarLogger.Debugf("-------close2 := %s", key)
t.Clients[key].C.Close()
}
delete(t.Clients, key)
}
func (t *TcpClient) clear(key string) {
t.Lock()
defer t.Unlock()
t.Clients[key].C.Close()
globals.SugarLogger.Debugf("-------close3 := %s", key)
delete(t.Clients, key)
close(t.MsgMap[key])
delete(t.MsgMap, key)
close(t.CallBackMap[key])
delete(t.CallBackMap, key)
delete(t.TimeoutMap, key)
}
//添加到连接池中
func addConn(c net.Conn, t *TcpClient, key string, status int) {
t.Lock()
@@ -326,18 +340,6 @@ func (t *TcpClient) GetCallbackChan(key string) string {
return <-t.CallBackMap[key]
}
func (t *TcpClient) clear(key string) {
t.Lock()
defer t.Unlock()
t.Clients[key].C.Close()
delete(t.Clients, key)
close(t.MsgMap[key])
delete(t.MsgMap, key)
close(t.CallBackMap[key])
delete(t.CallBackMap, key)
delete(t.TimeoutMap, key)
}
func NewTcpClient() *TcpClient {
t := &TcpClient{
Clients: make(map[string]*PrintInfo),