Skip to content

Commit

Permalink
Fix race in reload and gateway sublist check
Browse files Browse the repository at this point in the history
Signed-off-by: Waldemar Quevedo <wally@nats.io>
  • Loading branch information
wallyqs committed May 3, 2023
1 parent 91607d8 commit 938ffcb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/gateway.go
Expand Up @@ -2680,12 +2680,11 @@ 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.
hasSubs := acc.sl.Count() > 0
if !hasSubs {
acc.mu.RLock()
hasSubs = acc.siReply != nil
acc.mu.RUnlock()
}
// Need to grab the lock here since sublist can change during reload.
acc.mu.RLock()
hasSubs := acc.sl.Count() > 0 || acc.siReply != nil
acc.mu.RUnlock()

// If there is at least a subscription, possibly send RS-
if hasSubs {
sendProto := false
Expand Down

0 comments on commit 938ffcb

Please sign in to comment.