mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Don't wake up select if it was already woken up (#2863)
This avoids calling WakeupSelect() for each node instead of just once.
This commit is contained in:
parent
7fe1a4a78b
commit
fbe44761c0
@ -1321,10 +1321,10 @@ void CConnman::ThreadSocketHandler()
|
||||
}
|
||||
}
|
||||
|
||||
isInSelect = true;
|
||||
wakeupSelectNeeded = true;
|
||||
int nSelect = select(have_fds ? hSocketMax + 1 : 0,
|
||||
&fdsetRecv, &fdsetSend, &fdsetError, &timeout);
|
||||
isInSelect = false;
|
||||
wakeupSelectNeeded = false;
|
||||
if (interruptNet)
|
||||
return;
|
||||
|
||||
@ -1521,6 +1521,8 @@ void CConnman::WakeSelect()
|
||||
LogPrint("net", "write to wakeupPipe failed\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
wakeupSelectNeeded = false;
|
||||
}
|
||||
|
||||
|
||||
@ -3236,7 +3238,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg, bool allowOpti
|
||||
if (optimisticSend == true)
|
||||
nBytesSent = SocketSendData(pnode);
|
||||
// wake up select() call in case there was no pending data before (so it was not selecting this socket for sending)
|
||||
else if (!hasPendingData && isInSelect)
|
||||
else if (!hasPendingData && wakeupSelectNeeded)
|
||||
WakeSelect();
|
||||
}
|
||||
if (nBytesSent)
|
||||
|
@ -546,7 +546,7 @@ private:
|
||||
/** a pipe which is added to select() calls to wakeup before the timeout */
|
||||
int wakeupPipe[2]{-1,-1};
|
||||
#endif
|
||||
std::atomic<bool> isInSelect{false};
|
||||
std::atomic<bool> wakeupSelectNeeded{false};
|
||||
|
||||
std::thread threadDNSAddressSeed;
|
||||
std::thread threadSocketHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user