mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-24 22:31:37 +02: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 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 https://github.com/bitcoin-core/libmultiprocess/pull/160 to work effectively.
This commit is contained in:
12
src/init.cpp
12
src/init.cpp
@@ -33,6 +33,7 @@
|
|||||||
#include <interfaces/ipc.h>
|
#include <interfaces/ipc.h>
|
||||||
#include <interfaces/mining.h>
|
#include <interfaces/mining.h>
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
|
#include <ipc/exception.h>
|
||||||
#include <kernel/caches.h>
|
#include <kernel/caches.h>
|
||||||
#include <kernel/context.h>
|
#include <kernel/context.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
@@ -298,6 +299,14 @@ void Shutdown(NodeContext& node)
|
|||||||
StopREST();
|
StopREST();
|
||||||
StopRPC();
|
StopRPC();
|
||||||
StopHTTPServer();
|
StopHTTPServer();
|
||||||
|
for (auto& client : node.chain_clients) {
|
||||||
|
try {
|
||||||
|
client->stop();
|
||||||
|
} catch (const ipc::Exception& e) {
|
||||||
|
LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what());
|
||||||
|
client.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
StopMapPort();
|
StopMapPort();
|
||||||
|
|
||||||
// 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
|
||||||
@@ -370,9 +379,6 @@ void Shutdown(NodeContext& node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& client : node.chain_clients) {
|
|
||||||
client->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If any -ipcbind clients are still connected, disconnect them now so they
|
// If any -ipcbind clients are still connected, disconnect them now so they
|
||||||
// do not block shutdown.
|
// do not block shutdown.
|
||||||
|
Reference in New Issue
Block a user