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

+6 -1
View File
@@ -753,7 +753,12 @@ func (d *AuthenticatedGossiper) stop() {
log.Debug("Authenticated Gossiper is stopping")
defer log.Debug("Authenticated Gossiper stopped")
d.blockEpochs.Cancel()
// `blockEpochs` is only initialized in the start routine so we make
// sure we don't panic here in the case where the `Stop` method is
// called when the `Start` method does not complete.
if d.blockEpochs != nil {
d.blockEpochs.Cancel()
}
d.syncMgr.Stop()