aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-07-17 17:12:00 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-07-17 17:13:11 +0200
commit89bb0365b97af7a6f46b010ceb9ff31627a8f9db (patch)
tree55e3db7b60363ffb039988a1e6d312cd246ab274 /src/init.cpp
parent2b0179d8a9b75397937126b36114df0dddeab40c (diff)
parentdba485d65168794d8be39bd5e8de8777e7085434 (diff)
Merge #10832: init: Factor out AppInitLockDataDirectory and fix startup core dump issue
dba485d init: Factor out AppInitLockDataDirectory (Wladimir J. van der Laan) Pull request description: Alternative to #10818, alternative solution to #10815. After this change: All the AppInit steps before and inclusive AppInitLockDataDirectory must not have Shutdown() called in case of failure. Only when AppInitMain fails, Shutdown should be called. Changes the GUI and bitcoind code to consistently do this. Tree-SHA512: 393e1a0ae05eb8e791025069e3ac4f6f3cdeb459ec63feda85d01cf6696ab3fed7632b6a0ac3641b8c7015af51d46756b5bba77f5e5f0c446f0c2dea58bbc92e
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 1e85642019..d9b98be739 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1170,13 +1170,13 @@ bool AppInitSanityChecks()
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), _(PACKAGE_NAME)));
// Probe the data directory lock to give an early error message, if possible
+ // We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
+ // and a fork will cause weird behavior to it.
return LockDataDirectory(true);
}
-bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
+bool AppInitLockDataDirectory()
{
- const CChainParams& chainparams = Params();
- // ********************************************************* Step 4a: application initialization
// After daemonization get the data directory lock again and hold on to it until exit
// This creates a slight window for a race condition to happen, however this condition is harmless: it
// will at most make us exit without printing a message to console.
@@ -1184,7 +1184,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// Detailed error printed inside LockDataDirectory
return false;
}
+ return true;
+}
+bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
+{
+ const CChainParams& chainparams = Params();
+ // ********************************************************* Step 4a: application initialization
#ifndef WIN32
CreatePidFile(GetPidFile(), getpid());
#endif