From 8b9adca4461d0cb6bdfca7b74228d430b9b9d116 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 20 Dec 2013 11:48:22 +0100 Subject: Allow `-noserver` with bitcoind Allow running bitcoind without server. - Default to -server mode (of course) for bitcoind with SoftSetBoolArg - Remove fForceServer argument from AppInit2 - Move fDaemon to a static variable in bitcoind --- src/bitcoind.cpp | 7 ++++++- src/init.cpp | 16 +++------------- src/init.h | 2 +- src/qt/bitcoin.cpp | 2 +- src/util.h | 1 - 5 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index de71fde9bc..5d87218844 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -30,6 +30,8 @@ * Use the buttons Namespaces, Classes or Files at the top of the page to start navigating the code. */ +static bool fDaemon; + void DetectShutdownThread(boost::thread_group* threadGroup) { bool fShutdown = ShutdownRequested(); @@ -108,6 +110,8 @@ bool AppInit(int argc, char* argv[]) fDaemon = GetBoolArg("-daemon", false); if (fDaemon) { + fprintf(stdout, "Bitcoin server starting\n"); + // Daemonize pid_t pid = fork(); if (pid < 0) @@ -127,9 +131,10 @@ bool AppInit(int argc, char* argv[]) fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); } #endif + SoftSetBoolArg("-server", true); detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup)); - fRet = AppInit2(threadGroup, true); + fRet = AppInit2(threadGroup); } catch (std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); diff --git a/src/init.cpp b/src/init.cpp index b5d784dc58..275985604e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -242,10 +242,7 @@ std::string HelpMessage(HelpMessageMode hmm) strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n"; strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n"; strUsage += " " + _("This is intended for regression testing tools and app development.") + "\n"; - if (hmm == HMM_BITCOIN_QT) - { - strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; - } + strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; if (hmm == HMM_BITCOIND) { @@ -356,7 +353,7 @@ void ThreadImport(std::vector vImportFiles) /** Initialize bitcoin. * @pre Parameters should be parsed and config file should be read. */ -bool AppInit2(boost::thread_group& threadGroup, bool fForceServer) +bool AppInit2(boost::thread_group& threadGroup) { // ********************************************************* Step 1: setup #ifdef _MSC_VER @@ -483,11 +480,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer) else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS) nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; - if (fDaemon || fForceServer) - fServer = true; - else - fServer = GetBoolArg("-server", false); - + fServer = GetBoolArg("-server", false); fPrintToConsole = GetBoolArg("-printtoconsole", false); fLogTimestamps = GetBoolArg("-logtimestamps", true); #ifdef ENABLE_WALLET @@ -569,9 +562,6 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer) LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD); std::ostringstream strErrors; - if (fDaemon) - fprintf(stdout, "Bitcoin server starting\n"); - if (nScriptCheckThreads) { LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads); for (int i=0; istart(200); - if(AppInit2(threadGroup, false)) + if(AppInit2(threadGroup)) { { // Put this in a block, so that the Model objects are cleaned up before diff --git a/src/util.h b/src/util.h index 3922872e06..c6a1318fd7 100644 --- a/src/util.h +++ b/src/util.h @@ -121,7 +121,6 @@ extern std::map > mapMultiArgs; extern bool fDebug; extern bool fPrintToConsole; extern bool fPrintToDebugLog; -extern bool fDaemon; extern bool fServer; extern std::string strMiscWarning; extern bool fNoListen; -- cgit v1.2.3