net: rework the way that the messagehandler sleeps
commitc5a8b1b946b1ab0bb82bd4270b2a40f5731abcff
authorCory Fields <cory-nospam-@coryfields.com>
Sat, 31 Dec 2016 07:05:26 +0000 (31 02:05 -0500)
committerCory Fields <cory-nospam-@coryfields.com>
Fri, 13 Jan 2017 04:05:24 +0000 (12 23:05 -0500)
treea1ee1e54db0ae10d0641c2a6c1ff5189125cb681
parentc72cc88ed39652e44b5be48e9455f6f395bd7e83
net: rework the way that the messagehandler sleeps

In order to sleep accurately, the message handler needs to know if _any_ node
has more processing that it should do before the entire thread sleeps.

Rather than returning a value that represents whether ProcessMessages
encountered a message that should trigger a disconnnect, interpret the return
value as whether or not that node has more work to do.

Also, use a global fProcessWake value that can be set by other threads,
which takes precedence (for one cycle) over the messagehandler's decision.

Note that the previous behavior was to only process one message per loop
(except in the case of a bad checksum or invalid header). That was changed in
PR #3180.

The only change here in that regard is that the current node now falls to the
back of the processing queue for the bad checksum/invalid header cases.
src/net.cpp
src/net.h
src/net_processing.cpp
src/net_processing.h