multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start method of a subsystem did not successfully finish therefore we need to make sure we guard the stop methods for potential panics if some variables are not initialized in the contructors of the subsystems.
This commit is contained in:
10 files changed
+58
-14
No files matched your search
@@ -226,11 +226,17 @@ func (c *ChannelEventStore) Stop() error {
|
||||
|
||||
// Stop the ticker after the goroutine reading from it has exited, to
|
||||
// avoid a race.
|
||||
c.cfg.FlapCountTicker.Stop()
|
||||
var err error
|
||||
if c.cfg.FlapCountTicker == nil {
|
||||
err = fmt.Errorf("ChannelEventStore FlapCountTicker not " +
|
||||
"initialized")
|
||||
} else {
|
||||
c.cfg.FlapCountTicker.Stop()
|
||||
}
|
||||
|
||||
log.Debugf("ChannelEventStore shutdown complete")
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// addChannel checks whether we are already tracking a channel's peer, creates a
|
||||
|
||||
Reference in new issue
Block a user