From 44d9e9917c3b67674833fcd8d611f18d2eb366df Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Mon, 14 Feb 2022 15:34:35 -0800 Subject: [PATCH] pubsub: check for termination in UnsubscribeAll (#7820) This check was correctly handled in Unsubscribe, but not UnsubscribeAll. --- internal/pubsub/pubsub.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/pubsub/pubsub.go b/internal/pubsub/pubsub.go index 5f6a1ee3b..707f9cb13 100644 --- a/internal/pubsub/pubsub.go +++ b/internal/pubsub/pubsub.go @@ -281,6 +281,9 @@ func (s *Server) UnsubscribeAll(ctx context.Context, clientID string) error { s.subs.Lock() defer s.subs.Unlock() + if s.subs.index == nil { + return ErrServerStopped + } evict := s.subs.index.findClientID(clientID) if len(evict) == 0 { return ErrSubscriptionNotFound