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:
ziggie committed 2024-07-31 14:43:34 +02:00
1 parent e19f891453
commit 02c1264c53
10 files changed
+58 -14

No files matched your search

+8 -2
View File
@@ -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