mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
ipc: Handle bitcoin-wallet disconnections
This fixes an error reported by Antoine Poinsot <darosior@protonmail.com> in https://github.com/bitcoin-core/libmultiprocess/issues/123 that does not happen in master, but does happen with https://github.com/bitcoin/bitcoin/pull/10102 applied, where if the child bitcoin-wallet process is killed (either by an external signal or by Ctrl-C as reported in the issue) the bitcoin-node process will not shutdown cleanly after that because chain client flush() calls will fail. This change fixes the problem by handling ipc::Exception errors thrown during the flush() calls, and it relies on the fixes to disconnect detection implemented in https://github.com/bitcoin-core/libmultiprocess/pull/160 to work effectively.
This commit is contained in:
parent
db845b915f
commit
5b38e62ccb
1 changed files with 9 additions and 3 deletions
12
src/init.cpp
12
src/init.cpp
|
@ -33,6 +33,7 @@
|
|||
#include <interfaces/ipc.h>
|
||||
#include <interfaces/mining.h>
|
||||
#include <interfaces/node.h>
|
||||
#include <ipc/exception.h>
|
||||
#include <kernel/caches.h>
|
||||
#include <kernel/context.h>
|
||||
#include <key.h>
|
||||
|
@ -298,8 +299,13 @@ void Shutdown(NodeContext& node)
|
|||
StopREST();
|
||||
StopRPC();
|
||||
StopHTTPServer();
|
||||
for (const auto& client : node.chain_clients) {
|
||||
client->flush();
|
||||
for (auto& client : node.chain_clients) {
|
||||
try {
|
||||
client->flush();
|
||||
} catch (const ipc::Exception& e) {
|
||||
LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what());
|
||||
client.reset();
|
||||
}
|
||||
}
|
||||
StopMapPort();
|
||||
|
||||
|
@ -374,7 +380,7 @@ void Shutdown(NodeContext& node)
|
|||
}
|
||||
}
|
||||
for (const auto& client : node.chain_clients) {
|
||||
client->stop();
|
||||
if (client) client->stop();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ZMQ
|
||||
|
|
Loading…
Add table
Reference in a new issue