client revamping race condition

This commit is contained in:
shoopea 2019-07-31 14:54:20 +08:00
parent d7bcdb0108
commit 74b6b141f0

View File

@ -571,6 +571,7 @@ func MQTidyKeepAliveWorker() {
t := time.Now()
muxClients.Lock()
for id, clt := range clients {
clt.Mux.Lock()
if clt.Active && clt.HeartBeat.Add(3*KeepAliveHeartBeatSeconds*time.Second).Before(time.Now()) {
msgs, err := clt.MQ.Channel.QueuePurge(clt.MQ.Queue.Name, false)
logOnError(err, "MQTidyKeepAliveWorker : Channel.QueuePurge()")
@ -592,6 +593,7 @@ func MQTidyKeepAliveWorker() {
TGCmdQueue <- cmd
clt.Active = false
}
clt.Mux.Unlock()
}
muxClients.Unlock()
time.Sleep(time.Until(t.Add(time.Second)))