From 1b892a974d6667facd778c048b70e27827e53f07 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Tue, 2 May 2023 17:36:08 -0700 Subject: [PATCH] Fix race in reload and gateway sublist check Signed-off-by: Waldemar Quevedo --- server/gateway.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/gateway.go b/server/gateway.go index 35b50a1264c..886d6a59cea 100644 --- a/server/gateway.go +++ b/server/gateway.go @@ -2680,7 +2680,10 @@ func (s *Server) gatewayHandleSubjectNoInterest(c *client, acc *Account, accName // If there is no subscription for this account, we would normally // send an A-, however, if this account has the internal subscription // for service reply, send a specific RS- for the subject instead. + // Need to grab the lock here since sublist can change during reload. + acc.mu.RLock() hasSubs := acc.sl.Count() > 0 + acc.mu.RUnlock() if !hasSubs { acc.mu.RLock() hasSubs = acc.siReply != nil