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