|
|
|
@ -68,27 +68,9 @@ CCriticalSection cs_vAddedNodes;
@@ -68,27 +68,9 @@ CCriticalSection cs_vAddedNodes;
|
|
|
|
|
|
|
|
|
|
static CSemaphore *semOutbound = NULL; |
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Handlers that need to be registered
|
|
|
|
|
//
|
|
|
|
|
static ProcessMessagesHandler fnProcessMessages = NULL; |
|
|
|
|
static SendMessagesHandler fnSendMessages = NULL; |
|
|
|
|
static StartShutdownHandler fnStartShutdown = NULL; |
|
|
|
|
|
|
|
|
|
void SetProcessMessagesHandler(ProcessMessagesHandler handler) |
|
|
|
|
{ |
|
|
|
|
fnProcessMessages = handler; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SetSendMessagesHandler(SendMessagesHandler handler) |
|
|
|
|
{ |
|
|
|
|
fnSendMessages = handler; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SetStartShutdownHandler(StartShutdownHandler handler) |
|
|
|
|
{ |
|
|
|
|
fnStartShutdown = handler; |
|
|
|
|
} |
|
|
|
|
// Signals for message handling
|
|
|
|
|
static CNodeSignals g_signals; |
|
|
|
|
CNodeSignals& GetNodeSignals() { return g_signals; } |
|
|
|
|
|
|
|
|
|
void AddOneShot(string strDest) |
|
|
|
|
{ |
|
|
|
@ -1646,7 +1628,7 @@ void ThreadMessageHandler()
@@ -1646,7 +1628,7 @@ void ThreadMessageHandler()
|
|
|
|
|
{ |
|
|
|
|
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); |
|
|
|
|
if (lockRecv) |
|
|
|
|
if (!ProcessMessages(pnode)) |
|
|
|
|
if (!g_signals.ProcessMessages(pnode)) |
|
|
|
|
pnode->CloseSocketDisconnect(); |
|
|
|
|
} |
|
|
|
|
boost::this_thread::interruption_point(); |
|
|
|
@ -1654,8 +1636,8 @@ void ThreadMessageHandler()
@@ -1654,8 +1636,8 @@ void ThreadMessageHandler()
|
|
|
|
|
// Send messages
|
|
|
|
|
{ |
|
|
|
|
TRY_LOCK(pnode->cs_vSend, lockSend); |
|
|
|
|
if (lockSend && fnSendMessages) |
|
|
|
|
fnSendMessages(pnode, pnode == pnodeTrickle); |
|
|
|
|
if (lockSend) |
|
|
|
|
g_signals.SendMessages(pnode, pnode == pnodeTrickle); |
|
|
|
|
} |
|
|
|
|
boost::this_thread::interruption_point(); |
|
|
|
|
} |
|
|
|
|