diff options
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/src/init.cpp b/src/init.cpp index eecbc83ed..2be0027a5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -40,10 +40,13 @@ void Shutdown(void* parg) static CCriticalSection cs_Shutdown; static bool fTaken; bool fFirstThread = false; - TRY_CRITICAL_BLOCK(cs_Shutdown) { - fFirstThread = !fTaken; - fTaken = true; + TRY_LOCK(cs_Shutdown, lockShutdown); + if (lockShutdown) + { + fFirstThread = !fTaken; + fTaken = true; + } } static bool fExit; if (fFirstThread) @@ -171,6 +174,7 @@ bool AppInit2(int argc, char* argv[]) " -splash \t\t " + _("Show splash screen on startup (default: 1)") + "\n" + " -datadir=<dir> \t\t " + _("Specify data directory") + "\n" + " -dbcache=<n> \t\t " + _("Set database cache size in megabytes (default: 25)") + "\n" + + " -dblogsize=<n> \t\t " + _("Set database disk log size in megabytes (default: 100)") + "\n" + " -timeout=<n> \t " + _("Specify connection timeout (in milliseconds)") + "\n" + " -proxy=<ip:port> \t " + _("Connect through socks4 proxy") + "\n" + " -dns \t " + _("Allow DNS lookups for addnode and connect") + "\n" + @@ -221,14 +225,12 @@ bool AppInit2(int argc, char* argv[]) " -checkblocks=<n> \t\t " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" + " -checklevel=<n> \t\t " + _("How thorough the block verification is (0-6, default: 1)") + "\n"; -#ifdef USE_SSL strUsage += string() + _("\nSSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n" + " -rpcssl \t " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n" + " -rpcsslcertificatechainfile=<file.cert>\t " + _("Server certificate file (default: server.cert)") + "\n" + " -rpcsslprivatekeyfile=<file.pem> \t " + _("Server private key (default: server.pem)") + "\n" + " -rpcsslciphers=<ciphers> \t " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n"; -#endif strUsage += string() + " -? \t\t " + _("This help message") + "\n"; @@ -305,11 +307,11 @@ bool AppInit2(int argc, char* argv[]) } #endif - if (!fDebug && !pszSetDataDir[0]) + if (!fDebug) ShrinkDebugFile(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf("Bitcoin version %s\n", FormatFullVersion().c_str()); - printf("Default data directory %s\n", GetDefaultDataDir().c_str()); + printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); + printf("Default data directory %s\n", GetDefaultDataDir().string().c_str()); if (GetBoolArg("-loadblockindextest")) { @@ -320,13 +322,13 @@ bool AppInit2(int argc, char* argv[]) } // Make sure only a single bitcoin process is using the data directory. - string strLockFile = GetDataDir() + "/.lock"; - FILE* file = fopen(strLockFile.c_str(), "a"); // empty lock file; created if it doesn't exist. + boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; + FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist. if (file) fclose(file); - static boost::interprocess::file_lock lock(strLockFile.c_str()); + static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); if (!lock.try_lock()) { - ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().c_str()), _("Bitcoin"), wxOK|wxMODAL); + ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().string().c_str()), _("Bitcoin"), wxOK|wxMODAL); return false; } @@ -582,20 +584,20 @@ bool AppInit2(int argc, char* argv[]) } #ifdef WIN32 -string StartupShortcutPath() +boost::filesystem::path StartupShortcutPath() { - return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk"; + return MyGetSpecialFolderPath(CSIDL_STARTUP, true) / "Bitcoin.lnk"; } bool GetStartOnSystemStartup() { - return filesystem::exists(StartupShortcutPath().c_str()); + return filesystem::exists(StartupShortcutPath()); } bool SetStartOnSystemStartup(bool fAutoStart) { // If the shortcut exists already, remove it for updating - remove(StartupShortcutPath().c_str()); + boost::filesystem::remove(StartupShortcutPath()); if (fAutoStart) { @@ -631,7 +633,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) { WCHAR pwsz[MAX_PATH]; // Ensure that the string is ANSI. - MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().c_str(), -1, pwsz, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().string().c_str(), -1, pwsz, MAX_PATH); // Save the link by calling IPersistFile::Save. hres = ppf->Save(pwsz, TRUE); ppf->Release(); @@ -657,15 +659,15 @@ boost::filesystem::path GetAutostartDir() namespace fs = boost::filesystem; char* pszConfigHome = getenv("XDG_CONFIG_HOME"); - if (pszConfigHome) return fs::path(pszConfigHome) / fs::path("autostart"); + if (pszConfigHome) return fs::path(pszConfigHome) / "autostart"; char* pszHome = getenv("HOME"); - if (pszHome) return fs::path(pszHome) / fs::path(".config/autostart"); + if (pszHome) return fs::path(pszHome) / ".config" / "autostart"; return fs::path(); } boost::filesystem::path GetAutostartFilePath() { - return GetAutostartDir() / boost::filesystem::path("bitcoin.desktop"); + return GetAutostartDir() / "bitcoin.desktop"; } bool GetStartOnSystemStartup() @@ -690,13 +692,7 @@ bool GetStartOnSystemStartup() bool SetStartOnSystemStartup(bool fAutoStart) { if (!fAutoStart) - { -#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION >= 3 - unlink(GetAutostartFilePath().string().c_str()); -#else - unlink(GetAutostartFilePath().native_file_string().c_str()); -#endif - } + boost::filesystem::remove(GetAutostartFilePath()); else { char pszExePath[MAX_PATH+1]; |