mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 11:04:42 -07:00
We were having issues with the account being changed for the internal system client.
This changes when we are sending internal messages through the shared internal sendq but to a different account. We will now use an internal client that is only accessible to the send loop. Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -252,7 +252,7 @@ RESET:
|
||||
s.mu.Unlock()
|
||||
return
|
||||
}
|
||||
c := s.sys.client
|
||||
sysc := s.sys.client
|
||||
resetCh := s.sys.resetCh
|
||||
sysacc := s.sys.account
|
||||
sendq := s.sys.sendq
|
||||
@@ -272,6 +272,10 @@ RESET:
|
||||
warnFreq := time.Second
|
||||
last := time.Now().Add(-warnFreq)
|
||||
|
||||
// Internal client not generally accessible for when we
|
||||
// need to change accounts from the system account.
|
||||
ic := s.createInternalAccountClient()
|
||||
|
||||
for s.eventsRunning() {
|
||||
// Setup information for next message
|
||||
if len(sendq) > warnThresh && time.Since(last) >= warnFreq {
|
||||
@@ -303,14 +307,21 @@ RESET:
|
||||
}
|
||||
}
|
||||
|
||||
// Setup our client. If the user wants to use a non-system account use our internal
|
||||
// account scoped here so that we are not changing out accounts for the system client.
|
||||
var c *client
|
||||
if pm.acc != nil && pm.acc != sysacc {
|
||||
c = ic
|
||||
} else {
|
||||
c = sysc
|
||||
pm.acc = nil
|
||||
}
|
||||
|
||||
// Grab client lock.
|
||||
c.mu.Lock()
|
||||
|
||||
// We can have an override for account here.
|
||||
if pm.acc != nil {
|
||||
c.acc = pm.acc
|
||||
} else {
|
||||
c.acc = sysacc
|
||||
}
|
||||
|
||||
// Prep internal structures needed to send message.
|
||||
|
||||
Reference in New Issue
Block a user