stan broker, fix race on subscribe

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2019-06-22 00:25:50 +03:00
parent c55078a1c3
commit a28169de2e

View File

@ -280,9 +280,13 @@ func (n *stanBroker) Publish(topic string, msg *broker.Message, opts ...broker.P
}
func (n *stanBroker) Subscribe(topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
n.RLock()
if n.conn == nil {
n.RUnlock()
return nil, errors.New("not connected")
}
n.RUnlock()
var ackSuccess bool
opt := broker.SubscribeOptions{