File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ NodeId nLastNodeId = 0;
100100CCriticalSection cs_nLastNodeId;
101101
102102static CSemaphore *semOutbound = NULL ;
103+ boost::condition_variable messageHandlerCondition;
103104
104105// Signals for message handling
105106static CNodeSignals g_signals;
@@ -532,8 +533,10 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
532533 pch += handled;
533534 nBytes -= handled;
534535
535- if (msg.complete ())
536+ if (msg.complete ()) {
536537 msg.nTime = GetTimeMicros ();
538+ messageHandlerCondition.notify_one ();
539+ }
537540 }
538541
539542 return true ;
@@ -1358,6 +1361,9 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
13581361
13591362void ThreadMessageHandler ()
13601363{
1364+ boost::mutex condition_mutex;
1365+ boost::unique_lock<boost::mutex> lock (condition_mutex);
1366+
13611367 SetThreadPriority (THREAD_PRIORITY_BELOW_NORMAL);
13621368 while (true )
13631369 {
@@ -1417,7 +1423,7 @@ void ThreadMessageHandler()
14171423 }
14181424
14191425 if (fSleep )
1420- MilliSleep ( 100 );
1426+ messageHandlerCondition. timed_wait (lock, boost::posix_time::microsec_clock::universal_time () + boost::posix_time::milliseconds ( 100 ) );
14211427 }
14221428}
14231429
You can’t perform that action at this time.
0 commit comments