Browse Source

possible fix for pause on shutdown. thread names in macos for easier debugging.

cl-refactor
subtly 10 years ago
parent
commit
110c1099b6
  1. 9
      libdevcore/Log.cpp
  2. 2
      libp2p/RLPxHandshake.h

9
libdevcore/Log.cpp

@ -24,6 +24,9 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#ifdef __APPLE__
#include <pthread.h>
#endif
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include "Guards.h" #include "Guards.h"
using namespace std; using namespace std;
@ -168,7 +171,7 @@ extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* l
string dev::getThreadName() string dev::getThreadName()
{ {
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
char buffer[128]; char buffer[128];
pthread_getname_np(pthread_self(), buffer, 127); pthread_getname_np(pthread_self(), buffer, 127);
buffer[127] = 0; buffer[127] = 0;
@ -180,8 +183,10 @@ string dev::getThreadName()
void dev::setThreadName(string const& _n) void dev::setThreadName(string const& _n)
{ {
#ifdef __linux__ #if defined(__linux__)
pthread_setname_np(pthread_self(), _n.c_str()); pthread_setname_np(pthread_self(), _n.c_str());
#elsif defined(__APPLE__)
pthread_setname_np(_n.c_str());
#else #else
g_logThreadName.m_name.reset(new std::string(_n)); g_logThreadName.m_name.reset(new std::string(_n));
#endif #endif

2
libp2p/RLPxHandshake.h

@ -74,7 +74,7 @@ public:
void start() { transition(); } void start() { transition(); }
/// Cancels handshake preventing /// Cancels handshake preventing
void cancel() { m_cancel = true; } void cancel() { m_cancel = true; m_socket->close(); }
protected: protected:
/// Write Auth message to socket and transitions to AckAuth. /// Write Auth message to socket and transitions to AckAuth.

Loading…
Cancel
Save