mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Merge pull request #1815 from nats-io/jscfix
Routes send subscriptions by utilizing random clients from an account.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user