Skip to content

Commit 2581258

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/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 stop() calls will fail. This change fixes the problem by handling ipc::Exception errors thrown during the stop() calls, and it relies on the fixes to disconnect detection implemented in bitcoin-core/libmultiprocess#160 to work effectively.
1 parent 2160995 commit 2581258

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,6 +299,14 @@ void Shutdown(NodeContext& node)
298299
StopREST();
299300
StopRPC();
300301
StopHTTPServer();
302+
for (auto& client : node.chain_clients) {
303+
try {
304+
client->stop();
305+
} catch (const ipc::Exception& e) {
306+
LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what());
307+
client.reset();
308+
}
309+
}
301310
StopMapPort();
302311

303312
// Because these depend on each-other, we make sure that neither can be
@@ -370,9 +379,6 @@ void Shutdown(NodeContext& node)
370379
}
371380
}
372381
}
373-
for (const auto& client : node.chain_clients) {
374-
client->stop();
375-
}
376382

377383
// If any -ipcbind clients are still connected, disconnect them now so they
378384
// do not block shutdown.

0 commit comments

Comments
 (0)