Dont skip sendmessages (#3534)

* Revert "Only call SendMessages when ProcessMessages did some work or when some time passed"

This reverts commit 24ead62905.

* Only skip SendMessages() for fMasternode connections
This commit is contained in:
Alexander Block 2020-06-18 20:51:24 +02:00 committed by GitHub
parent 3f8a7b2068
commit c1f889c564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 19 deletions

View File

@ -2708,19 +2708,18 @@ void CConnman::OpenMasternodeConnection(const CAddress &addrConnect, bool probe)
void CConnman::ThreadMessageHandler()
{
int64_t nLastForceSendMessages = 0;
int64_t nLastSendMessagesTimeMasternodes = 0;
while (!flagInterruptMsgProc)
{
std::vector<CNode*> vNodesCopy = CopyNodeVector();
int64_t nNow = GetTimeMillis();
bool fMoreWork = false;
bool fForceSendMessages = false;
if (nNow - nLastForceSendMessages >= 100) {
fForceSendMessages = true;
nLastForceSendMessages = nNow;
bool fSkipSendMessagesForMasternodes = true;
if (GetTimeMillis() - nLastSendMessagesTimeMasternodes >= 100) {
fSkipSendMessagesForMasternodes = false;
nLastSendMessagesTimeMasternodes = GetTimeMillis();
}
for (CNode* pnode : vNodesCopy)
@ -2729,13 +2728,12 @@ void CConnman::ThreadMessageHandler()
continue;
// Receive messages
bool fDidWork = false;
bool fMoreNodeWork = m_msgproc->ProcessMessages(pnode, flagInterruptMsgProc, fDidWork);
bool fMoreNodeWork = m_msgproc->ProcessMessages(pnode, flagInterruptMsgProc);
fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
if (flagInterruptMsgProc)
return;
// Send messages
if (fDidWork || fForceSendMessages) {
if (!fSkipSendMessagesForMasternodes || !pnode->fMasternode) {
LOCK(pnode->cs_sendProcessing);
m_msgproc->SendMessages(pnode, flagInterruptMsgProc);
}

View File

@ -675,7 +675,7 @@ struct CombinerAll
class NetEventsInterface
{
public:
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt, bool &fRetDidWork) = 0;
virtual bool ProcessMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
virtual bool SendMessages(CNode* pnode, std::atomic<bool>& interrupt) = 0;
virtual void InitializeNode(CNode* pnode) = 0;
virtual void FinalizeNode(NodeId id, bool& update_connection_time) = 0;

View File

@ -3597,7 +3597,7 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman, bool en
return false;
}
bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc, bool &fRetDidWork)
bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc)
{
const CChainParams& chainparams = Params();
//
@ -3609,17 +3609,13 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
// (x) data
//
bool fMoreWork = false;
fRetDidWork = false;
if (!pfrom->vRecvGetData.empty()) {
if (!pfrom->vRecvGetData.empty())
ProcessGetData(pfrom, chainparams, connman, interruptMsgProc);
fRetDidWork = true;
}
if (!pfrom->orphan_work_set.empty()) {
LOCK2(cs_main, g_cs_orphans);
ProcessOrphanTx(connman, pfrom->orphan_work_set);
fRetDidWork = true;
}
if (pfrom->fDisconnect)
@ -3643,7 +3639,6 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
pfrom->nProcessQueueSize -= msgs.front().vRecv.size() + CMessageHeader::HEADER_SIZE;
pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman->GetReceiveFloodSize();
fMoreWork = !pfrom->vProcessMsg.empty();
fRetDidWork = true;
}
CNetMessage& msg(msgs.front());

View File

@ -50,7 +50,7 @@ public:
/** Handle removal of a peer by updating various state and removing it from mapNodeState */
void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
/** Process protocol messages received from a given node */
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt, bool &fRetDidWork) override;
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
/**
* Send queued protocol messages to be sent to a give node.
*