This commit is contained in:
邹宗楠
2026-01-30 10:00:57 +08:00
parent 8a8f545656
commit 999c3d7ebe
3 changed files with 22 additions and 11 deletions

View File

@@ -370,11 +370,11 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
} }
} }
} else { } else {
globals.SugarLogger.Debugf("-------close1 := %s", key)
t.getClients(key).C.Close() t.getClients(key).C.Close()
close(t.MsgMap[key]) close(t.MsgMap[key])
close(t.CallBackMap[key]) close(t.CallBackMap[key])
t.delConn(key) //t.delConn(key)
t.clear(key)
// 链接出错,彻底删除换成 // 链接出错,彻底删除换成
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have { if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {

View File

@@ -159,7 +159,6 @@ func (t *TcpClient) clear(key string) {
t.Lock() t.Lock()
defer t.Unlock() defer t.Unlock()
t.Clients[key].C.Close() t.Clients[key].C.Close()
globals.SugarLogger.Debugf("-------close3 := %s", key)
delete(t.Clients, key) delete(t.Clients, key)
close(t.MsgMap[key]) close(t.MsgMap[key])
delete(t.MsgMap, key) delete(t.MsgMap, key)

View File

@@ -47,9 +47,11 @@ func (w *Worker) Start() {
} }
func (w *Worker) Stop() { func (w *Worker) Stop() {
go func() { w.quit <- true
w.quit <- true close(w.quit)
}() //go func() {
// w.quit <- true
//}()
} }
func NewPool(numWorkers int) *Pool { func NewPool(numWorkers int) *Pool {
@@ -79,14 +81,24 @@ func (p *Pool) Stop() {
} }
} }
//
//func (p *Pool) AddJob(job Job) {
// p.wg.Add(1)
// p.jobChannel <- func() {
// job()
// p.wg.Done()
// }
//}
func (p *Pool) AddJob(job Job) { func (p *Pool) AddJob(job Job) {
p.wg.Add(1) p.wg.Add(1)
p.jobChannel <- func() { go func() {
job() p.jobChannel <- func() {
p.wg.Done() defer p.wg.Done()
} job()
}
}()
} }
func (p *Pool) Wait() { func (p *Pool) Wait() {
p.wg.Wait() p.wg.Wait()
} }