1
This commit is contained in:
@@ -370,11 +370,11 @@ func HandleCheckTcpHeart(t *TcpClient, key string) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("-------close1 := %s", key)
|
||||
t.getClients(key).C.Close()
|
||||
close(t.MsgMap[key])
|
||||
close(t.CallBackMap[key])
|
||||
t.delConn(key)
|
||||
//t.delConn(key)
|
||||
t.clear(key)
|
||||
|
||||
// 链接出错,彻底删除换成
|
||||
if printRemoteAddrIP, have := PrintIpAndAddr.GetPrintIpAndAddr(key); have {
|
||||
|
||||
@@ -159,7 +159,6 @@ 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)
|
||||
|
||||
@@ -47,9 +47,11 @@ func (w *Worker) Start() {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -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) {
|
||||
p.wg.Add(1)
|
||||
p.jobChannel <- func() {
|
||||
job()
|
||||
p.wg.Done()
|
||||
}
|
||||
go func() {
|
||||
p.jobChannel <- func() {
|
||||
defer p.wg.Done()
|
||||
job()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (p *Pool) Wait() {
|
||||
p.wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user