mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -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
10
src/init.cpp
10
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,8 +299,13 @@ void Shutdown(NodeContext& node)
|
||||||
StopREST();
|
StopREST();
|
||||||
StopRPC();
|
StopRPC();
|
||||||
StopHTTPServer();
|
StopHTTPServer();
|
||||||
for (const auto& client : node.chain_clients) {
|
for (auto& client : node.chain_clients) {
|
||||||
|
try {
|
||||||
client->flush();
|
client->flush();
|
||||||
|
} catch (const ipc::Exception& e) {
|
||||||
|
LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what());
|
||||||
|
client.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StopMapPort();
|
StopMapPort();
|
||||||
|
|
||||||
|
@ -374,7 +380,7 @@ void Shutdown(NodeContext& node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& client : node.chain_clients) {
|
for (const auto& client : node.chain_clients) {
|
||||||
client->stop();
|
if (client) client->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_ZMQ
|
#ifdef ENABLE_ZMQ
|
||||||
|
|
Loading…
Add table
Reference in a new issue