|
|
@ -100,6 +100,7 @@ NodeId nLastNodeId = 0;
|
|
|
|
CCriticalSection cs_nLastNodeId;
|
|
|
|
CCriticalSection cs_nLastNodeId;
|
|
|
|
|
|
|
|
|
|
|
|
static CSemaphore *semOutbound = NULL;
|
|
|
|
static CSemaphore *semOutbound = NULL;
|
|
|
|
|
|
|
|
boost::condition_variable messageHandlerCondition;
|
|
|
|
|
|
|
|
|
|
|
|
// Signals for message handling
|
|
|
|
// Signals for message handling
|
|
|
|
static CNodeSignals g_signals;
|
|
|
|
static CNodeSignals g_signals;
|
|
|
@ -532,8 +533,10 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
|
|
|
pch += handled;
|
|
|
|
pch += handled;
|
|
|
|
nBytes -= handled;
|
|
|
|
nBytes -= handled;
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.complete())
|
|
|
|
if (msg.complete()) {
|
|
|
|
msg.nTime = GetTimeMicros();
|
|
|
|
msg.nTime = GetTimeMicros();
|
|
|
|
|
|
|
|
messageHandlerCondition.notify_one();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -1358,6 +1361,9 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
|
|
|
|
|
|
|
|
|
|
|
|
void ThreadMessageHandler()
|
|
|
|
void ThreadMessageHandler()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
boost::mutex condition_mutex;
|
|
|
|
|
|
|
|
boost::unique_lock<boost::mutex> lock(condition_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
|
|
|
|
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
|
|
|
|
while (true)
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1417,7 +1423,7 @@ void ThreadMessageHandler()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fSleep)
|
|
|
|
if (fSleep)
|
|
|
|
MilliSleep(100);
|
|
|
|
messageHandlerCondition.timed_wait(lock, boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|