Set internal client to non-default, avoid race

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2018-12-07 10:32:10 -08:00
parent be0acfd50c
commit 9c667cbdf9
2 changed files with 5 additions and 4 deletions

View File

@@ -335,6 +335,7 @@ type clientOpts struct {
}
var defaultOpts = clientOpts{Verbose: true, Pedantic: true, Echo: true}
var internalOpts = clientOpts{Verbose: false, Pedantic: false, Echo: false}
func init() {
rand.Seed(time.Now().UnixNano())

View File

@@ -620,7 +620,7 @@ func (s *Server) setSystemAccount(acc *Account) error {
s.sys = &internal{
account: acc,
client: &client{srv: s, kind: SYSTEM, opts: defaultOpts, msubs: -1, mpay: -1, start: time.Now(), last: time.Now()},
client: &client{srv: s, kind: SYSTEM, opts: internalOpts, msubs: -1, mpay: -1, start: time.Now(), last: time.Now()},
seq: 1,
sid: 1,
servers: make(map[string]*serverUpdate),
@@ -635,13 +635,13 @@ func (s *Server) setSystemAccount(acc *Account) error {
s.sys.wg.Add(1)
s.mu.Unlock()
// Register with the account.
s.sys.client.registerWithAccount(acc)
// Start our internal loop to serialize outbound messages.
// We do our own wg here since we will stop first during shutdown.
go s.internalSendLoop(&s.sys.wg)
// Register with the account.
s.sys.client.registerWithAccount(acc)
// Start up our general subscriptions
s.initEventTracking()