Skip to content

Commit

Permalink
Merge pull request #549 from UdjinM6/v0.12.0.x_msghand
Browse files Browse the repository at this point in the history
V0.12.0.x msghand
  • Loading branch information
evan82 committed Aug 18, 2015
2 parents 418a9ee + ade9792 commit 7fb5f58
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ NodeId nLastNodeId = 0;
CCriticalSection cs_nLastNodeId;

static CSemaphore *semOutbound = NULL;
boost::condition_variable messageHandlerCondition;

// Signals for message handling
static CNodeSignals g_signals;
Expand Down Expand Up @@ -601,8 +602,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;
Expand Down Expand Up @@ -1433,6 +1436,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)
{
Expand Down Expand Up @@ -1493,10 +1499,7 @@ void ThreadMessageHandler()
}

if (fSleep)
MilliSleep(1);

boost::this_thread::interruption_point();

messageHandlerCondition.timed_wait(lock, boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(100));
}
}

Expand Down

0 comments on commit 7fb5f58

Please sign in to comment.