broker stan: fix data race
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
bf0aecf4f6
commit
e545f8cbc4
6
stan.go
6
stan.go
@ -151,6 +151,10 @@ func (n *stanBroker) connect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
n.RLock()
|
||||
done := n.done
|
||||
n.RUnlock()
|
||||
|
||||
// wait loop
|
||||
for {
|
||||
select {
|
||||
@ -158,7 +162,7 @@ func (n *stanBroker) connect() error {
|
||||
case <-n.opts.Context.Done():
|
||||
return nil
|
||||
// call close, don't wait anymore
|
||||
case <-n.done:
|
||||
case <-done:
|
||||
return nil
|
||||
// in case of timeout fail with a timeout error
|
||||
case <-timeout:
|
||||
|
Loading…
Reference in New Issue
Block a user