check whether subscription or topics manager are nil before using them in client Close() (#113)

This commit is contained in:
Luca Moser
2021-03-18 03:02:49 +01:00
committed by GitHub
parent 7cc3949bbe
commit ccbe364f9f

View File

@@ -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))