From dba485d65168794d8be39bd5e8de8777e7085434 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 15 Jul 2017 10:46:06 +0200 Subject: init: Factor out AppInitLockDataDirectory 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. --- src/bitcoind.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/bitcoind.cpp') diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 374678310c..f3844e9d47 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -159,7 +159,12 @@ bool AppInit(int argc, char* argv[]) return false; #endif // HAVE_DECL_DAEMON } - + // Lock data directory after daemonization + if (!AppInitLockDataDirectory()) + { + // If locking the data directory failed, exit immediately + exit(EXIT_FAILURE); + } fRet = AppInitMain(threadGroup, scheduler); } catch (const std::exception& e) { -- cgit v1.2.3