Merge pull request #1815 from nats-io/jscfix

Routes send subscriptions by utilizing random clients from an account.
This commit is contained in:
Derek Collison
2021-01-15 18:26:38 -07:00
committed by GitHub
2 changed files with 12 additions and 1 deletions

View File

@@ -878,7 +878,9 @@ func (a *Account) randomClient() *client {
}
var c *client
for c = range a.clients {
break
if c.acc == a {
break
}
}
return c
}

View File

@@ -1048,6 +1048,14 @@ func (s *Server) setSystemAccount(acc *Account) error {
if acc.imports.services == nil {
acc.imports.services = make(map[string]*serviceImport)
}
// Create a dummy internal client for fast lookup for
// randomClient used in route xfer of subs. Also will
// be stable with account.
if acc.ic == nil {
acc.ic = s.createInternalAccountClient()
acc.ic.acc = acc
}
acc.mu.Unlock()
s.sys = &internal{
@@ -1063,6 +1071,7 @@ func (s *Server) setSystemAccount(acc *Account) error {
orphMax: 5 * eventsHBInterval,
chkOrph: 3 * eventsHBInterval,
}
s.sys.wg.Add(1)
s.mu.Unlock()