From eb4a7156ca715f4276ca3cc37b5cc2b0163e1ba5 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Wed, 5 Dec 2018 16:21:20 -0800 Subject: [PATCH] Hold Rlock on client remapping Signed-off-by: Derek Collison --- server/reload.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/server/reload.go b/server/reload.go index 5caa9db3..96add700 100644 --- a/server/reload.go +++ b/server/reload.go @@ -747,23 +747,20 @@ func (s *Server) reloadAuthorization() { // If account exist in latest config, "transfer" the account's // sublist and client map to the new account. acc.mu.RLock() - sl := acc.sl - clients := acc.clients - acc.mu.RUnlock() - newAcc.mu.Lock() - newAcc.sl = sl - if len(clients) > 0 { - newAcc.clients = make(map[*client]*client, len(clients)) - for _, c := range clients { + if len(acc.clients) > 0 { + newAcc.clients = make(map[*client]*client, len(acc.clients)) + for _, c := range acc.clients { newAcc.clients[c] = c } } + newAcc.sl = acc.sl + acc.mu.RUnlock() + // Check if current and new config of this account are same // in term of stream imports. if !acc.checkStreamImportsEqual(newAcc) { awcsti[newAcc.Name] = struct{}{} } - newAcc.mu.Unlock() } } // Gather clients that changed accounts. We will close them and they