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
@@ -261,7 +261,13 @@ func (i *InvoiceRegistry) Stop() error {
|
||||
log.Info("InvoiceRegistry shutting down...")
|
||||
defer log.Debug("InvoiceRegistry shutdown complete")
|
||||
|
||||
i.expiryWatcher.Stop()
|
||||
var err error
|
||||
if i.expiryWatcher == nil {
|
||||
err = fmt.Errorf("InvoiceRegistry expiryWatcher is not " +
|
||||
"initialized")
|
||||
} else {
|
||||
i.expiryWatcher.Stop()
|
||||
}
|
||||
|
||||
close(i.quit)
|
||||
|
||||
@@ -269,7 +275,7 @@ func (i *InvoiceRegistry) Stop() error {
|
||||
|
||||
log.Debug("InvoiceRegistry shutdown complete")
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// invoiceEvent represents a new event that has modified on invoice on disk.
|
||||
|
||||
Reference in new issue
Block a user