fix: 🐛 fixes race condition (#155)
- this race condition occurs when a client is disconnected or when hmq checks if client still alive Signed-off-by: Lucas Vieira <lucas.engen.cc@gmail.com>
This commit is contained in:
1 parent
94ff8e8405
commit
31864cdf2b
2 files changed
+5
-2
No files matched your search
+3
-1
@@ -195,8 +195,10 @@ func (c *client) retryDelivery() {
|
||||
c.resetRetryTimer()
|
||||
c.inflightMu.RLock()
|
||||
ilen := len(c.inflight)
|
||||
if c.conn == nil || ilen == 0 { //Reset timer when client offline OR inflight is empty
|
||||
|
||||
if c.mu.Lock(); c.conn == nil || ilen == 0 { //Reset timer when client offline OR inflight is empty
|
||||
c.inflightMu.RUnlock()
|
||||
c.mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user