fix router panic (#1254)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
f1e7ea3020
commit
b4a743898e
@ -368,9 +368,11 @@ func (r *router) advertiseEvents() error {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
// reset
|
||||
w.Stop()
|
||||
w = nil
|
||||
if w != nil {
|
||||
// reset
|
||||
w.Stop()
|
||||
w = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
@ -467,7 +469,9 @@ func (r *router) advertiseEvents() error {
|
||||
a.penalty += Penalty
|
||||
log.Debugf("Router advert %d for route %s %s event penalty: %f", hash, a.event.Route.Service, a.event.Route.Address, a.penalty)
|
||||
case <-r.exit:
|
||||
w.Stop()
|
||||
if w != nil {
|
||||
w.Stop()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -700,16 +704,15 @@ func (r *router) Stop() error {
|
||||
// extract the events
|
||||
r.drain()
|
||||
|
||||
r.sub.Lock()
|
||||
// close advert subscribers
|
||||
for id, sub := range r.subscribers {
|
||||
// close the channel
|
||||
close(sub)
|
||||
|
||||
// delete the subscriber
|
||||
r.sub.Lock()
|
||||
delete(r.subscribers, id)
|
||||
r.sub.Unlock()
|
||||
}
|
||||
r.sub.Unlock()
|
||||
}
|
||||
|
||||
// remove event chan
|
||||
|
Loading…
x
Reference in New Issue
Block a user