fix: ensure that deadlocks are actually resolved

The fix introduced in bitcoin#27981 (8c986d6b, dash#6067) is not
validated to work until bitcoin#28287, an upcoming backport.

As the latter has identified the former backport didn't pass validation,
let's fix it so that the latter tests succeed when they're backported
in an upcoming commit.
This commit is contained in:
Kittywhiskers Van Gogh 2024-09-18 23:12:00 +00:00
parent 19e7bf64c8
commit d1fce0b7ca
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -2255,6 +2255,7 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
for (CNode* pnode : nodes) { for (CNode* pnode : nodes) {
bool select_recv = !pnode->fHasRecvData; bool select_recv = !pnode->fHasRecvData;
bool select_send = !pnode->fCanSendData; bool select_send = !pnode->fCanSendData;
if (!select_recv && !select_send) continue;
LOCK(pnode->m_sock_mutex); LOCK(pnode->m_sock_mutex);
if (!pnode->m_sock) { if (!pnode->m_sock) {
@ -2625,9 +2626,7 @@ void CConnman::SocketHandlerConnected(const std::set<SOCKET>& recv_set,
// receiving data. This means properly utilizing TCP flow control signalling. // receiving data. This means properly utilizing TCP flow control signalling.
// * Otherwise, if there is space left in the receive buffer (!fPauseRecv), try // * Otherwise, if there is space left in the receive buffer (!fPauseRecv), try
// receiving data (which should succeed as the socket signalled as receivable). // receiving data (which should succeed as the socket signalled as receivable).
const auto& [to_send, more, _msg_type] = it->second->m_transport->GetBytesToSend(it->second->nSendMsgSize != 0); if (!it->second->fPauseRecv && !it->second->fDisconnect && it->second->nSendMsgSize == 0) {
const bool queue_is_empty{to_send.empty() && !more};
if (!it->second->fPauseRecv && !it->second->fDisconnect && queue_is_empty) {
it->second->AddRef(); it->second->AddRef();
vReceivableNodes.emplace(it->second); vReceivableNodes.emplace(it->second);
} }