mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-04 07:08:32 +00:00
check whether subscription or topics manager are nil before using them in client Close() (#113)
This commit is contained in:
@@ -794,6 +794,10 @@ func (c *client) Close() {
|
||||
if b != nil {
|
||||
b.removeClient(c)
|
||||
for _, sub := range subs {
|
||||
// guard against race condition where a client gets Close() but wasn't initialized yet fully
|
||||
if sub == nil || b.topicsMgr == nil {
|
||||
continue
|
||||
}
|
||||
err := b.topicsMgr.Unsubscribe([]byte(sub.topic), sub)
|
||||
if err != nil {
|
||||
log.Error("unsubscribe error, ", zap.Error(err), zap.String("ClientID", c.info.clientID))
|
||||
|
||||
Reference in New Issue
Block a user