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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n.RLock()
|
||||||
|
done := n.done
|
||||||
|
n.RUnlock()
|
||||||
|
|
||||||
// wait loop
|
// wait loop
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -158,7 +162,7 @@ func (n *stanBroker) connect() error {
|
|||||||
case <-n.opts.Context.Done():
|
case <-n.opts.Context.Done():
|
||||||
return nil
|
return nil
|
||||||
// call close, don't wait anymore
|
// call close, don't wait anymore
|
||||||
case <-n.done:
|
case <-done:
|
||||||
return nil
|
return nil
|
||||||
// in case of timeout fail with a timeout error
|
// in case of timeout fail with a timeout error
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
|
Loading…
Reference in New Issue
Block a user