aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-10 11:06:18 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-04-10 11:06:27 -0400
commit3347ca48816c7a0aab61573b23d7f8d902c1dac3 (patch)
tree7a67000d6ba22b600c56f89e8d697a04d3979bd0
parent29893ec8751f51f281f694453bd439f92ccf3ab2 (diff)
parent7fcdec0f326f7fb547ec9c651871842cf518ea38 (diff)
downloadbitcoin-3347ca48816c7a0aab61573b23d7f8d902c1dac3.tar.xz
Merge #18526: Remove PID file at the very end
7fcdec0f326f7fb547ec9c651871842cf518ea38 Remove PID file at the very end (Hennadii Stepanov) Pull request description: While reproducing the bug from #18517, I've noticed that the `bitcoind.pid` file has already been removed when the `bitcoind` hangs. This PR makes `Shutdown()` keep the `bitcoind.pid` file available until the end. ACKs for top commit: MarcoFalke: ACK 7fcdec0f326f7fb547ec9c651871842cf518ea38 emilengler: utACK 7fcdec0f326f7fb547ec9c651871842cf518ea38 promag: Code review ACK 7fcdec0f326f7fb547ec9c651871842cf518ea38. theStack: Code review ACK 7fcdec0f326f7fb547ec9c651871842cf518ea38 Tree-SHA512: 9732ef34e137dbee70a06d922b316b8ea7b9a1c959cf8861b6940cd789336dc19ee468a4c3a28d95d1458076a48270c676b0ff27fec30cf57eced6ddab0a2a9b
-rw-r--r--src/init.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 437e934093..92faa77059 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -291,13 +291,6 @@ void Shutdown(NodeContext& node)
}
#endif
- try {
- if (!fs::remove(GetPidFile())) {
- LogPrintf("%s: Unable to remove PID file: File does not exist\n", __func__);
- }
- } catch (const fs::filesystem_error& e) {
- LogPrintf("%s: Unable to remove PID file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
- }
node.chain_clients.clear();
UnregisterAllValidationInterfaces();
GetMainSignals().UnregisterBackgroundSignalScheduler();
@@ -305,6 +298,15 @@ void Shutdown(NodeContext& node)
ECC_Stop();
if (node.mempool) node.mempool = nullptr;
node.scheduler.reset();
+
+ try {
+ if (!fs::remove(GetPidFile())) {
+ LogPrintf("%s: Unable to remove PID file: File does not exist\n", __func__);
+ }
+ } catch (const fs::filesystem_error& e) {
+ LogPrintf("%s: Unable to remove PID file: %s\n", __func__, fsbridge::get_filesystem_error_message(e));
+ }
+
LogPrintf("%s: done\n", __func__);
}