aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 1481ad917e..731c810935 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -100,6 +100,7 @@ NodeId nLastNodeId = 0;
CCriticalSection cs_nLastNodeId;
static CSemaphore *semOutbound = NULL;
+boost::condition_variable messageHandlerCondition;
// Signals for message handling
static CNodeSignals g_signals;
@@ -553,8 +554,10 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
pch += handled;
nBytes -= handled;
- if (msg.complete())
+ if (msg.complete()) {
msg.nTime = GetTimeMicros();
+ messageHandlerCondition.notify_one();
+ }
}
return true;
@@ -1379,6 +1382,9 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
void ThreadMessageHandler()
{
+ boost::mutex condition_mutex;
+ boost::unique_lock<boost::mutex> lock(condition_mutex);
+
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
while (true)
{
@@ -1438,7 +1444,7 @@ void ThreadMessageHandler()
}
if (fSleep)
- MilliSleep(100);
+ messageHandlerCondition.timed_wait(lock, boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(100));
}
}