From bced903ae52b63c59ffde51e5c6d5e16dad9aaf5 Mon Sep 17 00:00:00 2001 From: kjj2 Date: Sun, 30 Sep 2012 08:50:59 -0500 Subject: [PATCH 1/3] Add a backup warning to the encryptwallet RPC command --- src/rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index c77c5055723..67bd88c9205 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1479,7 +1479,7 @@ Value encryptwallet(const Array& params, bool fHelp) // slack space in .dat files; that is bad if the old data is // unencrypted private keys. So: CreateThread(Shutdown, NULL); - return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet"; + return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup."; } From d37a2fd8080cffde4ffbcb9927a66258e9fef39e Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 4 Oct 2012 07:56:57 +0200 Subject: [PATCH 2/3] Send --help message to stdout i.s.o stderr This allows fun stuff such as `bitcoin --help | less`, and more easy piping to files. Looking at other tools such as bash, gcc, they all send their help text to stdout. --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index c6712fa715a..5faa6043946 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -232,7 +232,7 @@ bool AppInit2(int argc, char* argv[]) #else // Remove tabs strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end()); - fprintf(stderr, "%s", strUsage.c_str()); + fprintf(stdout, "%s", strUsage.c_str()); #endif return false; } From b3f8f6ab9409d3e901d22c09b0346a5a47779496 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 4 Oct 2012 16:35:08 -0400 Subject: [PATCH 3/3] Avoid crashes at shutdown due to printf() in global destructors. --- src/util.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 49415fc3b73..62fa4c05755 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -194,8 +194,14 @@ inline int OutputDebugStringF(const char* pszFormat, ...) if (fileout) { static bool fStartedNewLine = true; - static boost::mutex mutexDebugLog; - boost::mutex::scoped_lock scoped_lock(mutexDebugLog); + + // This routine may be called by global destructors during shutdown. + // Since the order of destruction of static/global objects is undefined, + // allocate mutexDebugLog on the heap the first time this routine + // is called to avoid crashes during shutdown. + static boost::mutex* mutexDebugLog = NULL; + if (mutexDebugLog == NULL) mutexDebugLog = new boost::mutex(); + boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine)