aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 9d0f9ab347..4cb8a214da 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -51,6 +51,8 @@ namespace boost {
#endif
#include <io.h> /* for _commit */
#include "shlobj.h"
+#elif defined(__linux__)
+# include <sys/prctl.h>
#endif
using namespace std;
@@ -73,7 +75,7 @@ bool fLogTimestamps = false;
CMedianFilter<int64> vTimeOffsets(200,0);
bool fReopenDebugLog = false;
-// Init openssl library multithreading support
+// Init OpenSSL library multithreading support
static CCriticalSection** ppmutexOpenSSL;
void locking_callback(int mode, int i, const char* file, int line)
{
@@ -90,7 +92,7 @@ class CInit
public:
CInit()
{
- // Init openssl library multithreading support
+ // Init OpenSSL library multithreading support
ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*));
for (int i = 0; i < CRYPTO_num_locks(); i++)
ppmutexOpenSSL[i] = new CCriticalSection();
@@ -106,7 +108,7 @@ public:
}
~CInit()
{
- // Shutdown openssl library multithreading support
+ // Shutdown OpenSSL library multithreading support
CRYPTO_set_locking_callback(NULL);
for (int i = 0; i < CRYPTO_num_locks(); i++)
delete ppmutexOpenSSL[i];
@@ -1142,7 +1144,7 @@ void ShrinkDebugFile()
// "Never go to sea with two chronometers; take one or three."
// Our three time sources are:
// - System clock
-// - Median of other nodes's clocks
+// - Median of other nodes clocks
// - The user (asking the user to fix the system clock if the first two disagree)
//
static int64 nMockTime = 0; // For unit testing
@@ -1275,3 +1277,20 @@ void runCommand(std::string strCommand)
printf("runCommand error: system(%s) returned %d\n", strCommand.c_str(), nErr);
}
+void RenameThread(const char* name)
+{
+#if defined(PR_SET_NAME)
+ // Only the first 15 characters are used (16 - NUL terminator)
+ ::prctl(PR_SET_NAME, name, 0, 0, 0);
+#elif 0 && (defined(__FreeBSD__) || defined(__OpenBSD__))
+ // TODO: This is currently disabled because it needs to be verified to work
+ // on FreeBSD or OpenBSD first. When verified the '0 &&' part can be
+ // removed.
+ pthread_set_name_np(pthread_self(), name);
+#elif defined(MAC_OSX)
+ pthread_setname_np(name);
+#else
+ // Prevent warnings for unused parameters...
+ (void)name;
+#endif
+}