Skip to content

Commit 0b72656

Browse files
committed
ipc: Handle bitcoin-wallet disconnections
This fixes an error reported by Antoine Poinsot <[email protected]> in bitcoin-core/libmultiprocess#123 that does not happen in master, but does happen with bitcoin#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 bitcoin-core/libmultiprocess#160 to work effectively.
1 parent 55b4df0 commit 0b72656

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/init.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <interfaces/ipc.h>
3434
#include <interfaces/mining.h>
3535
#include <interfaces/node.h>
36+
#include <ipc/exception.h>
3637
#include <kernel/caches.h>
3738
#include <kernel/context.h>
3839
#include <key.h>
@@ -298,8 +299,13 @@ void Shutdown(NodeContext& node)
298299
StopREST();
299300
StopRPC();
300301
StopHTTPServer();
301-
for (const auto& client : node.chain_clients) {
302-
client->flush();
302+
for (auto& client : node.chain_clients) {
303+
try {
304+
client->flush();
305+
} catch (const ipc::Exception& e) {
306+
LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what());
307+
client.reset();
308+
}
303309
}
304310
StopMapPort();
305311

@@ -374,7 +380,7 @@ void Shutdown(NodeContext& node)
374380
}
375381
}
376382
for (const auto& client : node.chain_clients) {
377-
client->stop();
383+
if (client) client->stop();
378384
}
379385

380386
#ifdef ENABLE_ZMQ

0 commit comments

Comments
 (0)