From 8062ade7876d1d82b7385c09a3cdb6aa0b7ba490 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 12 Jul 2017 13:10:36 +0300 Subject: [PATCH] remove all clients (including closing all channels) on shutdown --- pubsub/pubsub.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index 264848161..ae642a4fb 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -216,7 +216,9 @@ loop: state.removeAll(cmd.clientID) } case shutdown: - state.reset() + for clientID, _ := range state.clients { + state.removeAll(clientID) + } break loop case sub: state.add(cmd.clientID, cmd.query, cmd.ch) @@ -286,11 +288,6 @@ func (state *state) removeAll(clientID string) { delete(state.clients, clientID) } -func (state *state) reset() { - state.queries = make(map[Query]map[string]chan<- interface{}) - state.clients = make(map[string]map[Query]struct{}) -} - func (state *state) send(msg interface{}, tags map[string]interface{}, slowClientStrategy overflowStrategy, logger log.Logger) { for q, clientToChannelMap := range state.queries { // NOTE we can use LRU cache to speed up common cases like query = "