mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
[net] Encapsulate CNode message polling
This commit is contained in:
parent
cc5cdf8776
commit
897e342d6e
3 changed files with 29 additions and 12 deletions
|
|
@ -4854,8 +4854,6 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
|
|||
{
|
||||
AssertLockHeld(g_msgproc_mutex);
|
||||
|
||||
bool fMoreWork = false;
|
||||
|
||||
PeerRef peer = GetPeerRef(pfrom->GetId());
|
||||
if (peer == nullptr) return false;
|
||||
|
||||
|
|
@ -4883,17 +4881,14 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
|
|||
// Don't bother if send buffer is too full to respond anyway
|
||||
if (pfrom->fPauseSend) return false;
|
||||
|
||||
std::list<CNetMessage> msgs;
|
||||
{
|
||||
LOCK(pfrom->cs_vProcessMsg);
|
||||
if (pfrom->vProcessMsg.empty()) return false;
|
||||
// Just take one message
|
||||
msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin());
|
||||
pfrom->nProcessQueueSize -= msgs.front().m_raw_message_size;
|
||||
pfrom->fPauseRecv = pfrom->nProcessQueueSize > m_connman.GetReceiveFloodSize();
|
||||
fMoreWork = !pfrom->vProcessMsg.empty();
|
||||
auto poll_result{pfrom->PollMessage(m_connman.GetReceiveFloodSize())};
|
||||
if (!poll_result) {
|
||||
// No message to process
|
||||
return false;
|
||||
}
|
||||
CNetMessage& msg(msgs.front());
|
||||
|
||||
CNetMessage& msg{poll_result->first};
|
||||
bool fMoreWork = poll_result->second;
|
||||
|
||||
TRACE6(net, inbound_message,
|
||||
pfrom->GetId(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue