diff --git a/socketserver/server/subscriptions.go b/socketserver/server/subscriptions.go index 007aea03..136fa603 100644 --- a/socketserver/server/subscriptions.go +++ b/socketserver/server/subscriptions.go @@ -156,8 +156,11 @@ func UnsubscribeSingleChat(client *ClientInfo, channelName string) { // - write lock to SubscriptionInfos // - write lock to ClientInfo func UnsubscribeAll(client *ClientInfo) { - if StopAcceptingConnections { - return // no need to remove from a high-contention list when the server is closing + select { + case <-StopAcceptingConnectionsCh: + // Skip high-contention client removal operations while server shutting down + return + default: } GlobalSubscriptionLock.Lock()