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
+2
-1
@@ -808,9 +808,10 @@ func (c *client) Close() {
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
|
||||
if c.conn != nil {
|
||||
if c.mu.Lock(); c.conn != nil {
|
||||
_ = c.conn.Close()
|
||||
c.conn = nil
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
if b == nil {
|
||||
|
||||
Reference in new issue
Block a user