Holding lock when accessing leaf node account for filtering

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2020-09-24 18:57:21 -04:00
parent d501a811b8
commit 371861ec59

View File

@@ -1765,8 +1765,13 @@ func (s *Server) Leafz(opts *LeafzOptions) (*Leafz, error) {
if len(s.leafs) > 0 {
lconns = make([]*client, 0, len(s.leafs))
for _, ln := range s.leafs {
if opts != nil && opts.Account != "" && ln.acc.Name != opts.Account {
continue
if opts != nil && opts.Account != "" {
ln.mu.Lock()
ok := ln.acc.Name == opts.Account
ln.mu.Unlock()
if !ok {
continue
}
}
lconns = append(lconns, ln)
}