Fix shutdown in case of errors during initialization
PR #10286 introduced a few steps which are not robust to early shutdown in initialization. Stumbled upon this with #11781, not sure if there are other scenarios that can trigger it, but it's harden against this in any case.
This commit is contained in:
parent
26efc220a1
commit
d31e5c1d0f
2 changed files with 8 additions and 3 deletions
|
@ -193,7 +193,7 @@ void Shutdown()
|
||||||
|
|
||||||
// Because these depend on each-other, we make sure that neither can be
|
// Because these depend on each-other, we make sure that neither can be
|
||||||
// using the other before destroying them.
|
// using the other before destroying them.
|
||||||
UnregisterValidationInterface(peerLogic.get());
|
if (peerLogic) UnregisterValidationInterface(peerLogic.get());
|
||||||
if (g_connman) g_connman->Stop();
|
if (g_connman) g_connman->Stop();
|
||||||
peerLogic.reset();
|
peerLogic.reset();
|
||||||
g_connman.reset();
|
g_connman.reset();
|
||||||
|
|
|
@ -49,8 +49,10 @@ void CMainSignals::UnregisterBackgroundSignalScheduler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainSignals::FlushBackgroundCallbacks() {
|
void CMainSignals::FlushBackgroundCallbacks() {
|
||||||
|
if (m_internals) {
|
||||||
m_internals->m_schedulerClient.EmptyQueue();
|
m_internals->m_schedulerClient.EmptyQueue();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) {
|
void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) {
|
||||||
pool.NotifyEntryRemoved.connect(boost::bind(&CMainSignals::MempoolEntryRemoved, this, _1, _2));
|
pool.NotifyEntryRemoved.connect(boost::bind(&CMainSignals::MempoolEntryRemoved, this, _1, _2));
|
||||||
|
@ -92,6 +94,9 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterAllValidationInterfaces() {
|
void UnregisterAllValidationInterfaces() {
|
||||||
|
if (!g_signals.m_internals) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
g_signals.m_internals->BlockChecked.disconnect_all_slots();
|
g_signals.m_internals->BlockChecked.disconnect_all_slots();
|
||||||
g_signals.m_internals->Broadcast.disconnect_all_slots();
|
g_signals.m_internals->Broadcast.disconnect_all_slots();
|
||||||
g_signals.m_internals->Inventory.disconnect_all_slots();
|
g_signals.m_internals->Inventory.disconnect_all_slots();
|
||||||
|
|
Loading…
Add table
Reference in a new issue