Skip to content

Commit

Permalink
fix: ensure that deadlocks are actually resolved
Browse files Browse the repository at this point in the history
The fix introduced in bitcoin#27981 (8c986d6, 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.
  • Loading branch information
kwvg committed Oct 2, 2024
1 parent 19e7bf6 commit d1fce0b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,7 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
for (CNode* pnode : nodes) {
bool select_recv = !pnode->fHasRecvData;
bool select_send = !pnode->fCanSendData;
if (!select_recv && !select_send) continue;

LOCK(pnode->m_sock_mutex);
if (!pnode->m_sock) {
Expand Down Expand Up @@ -2625,9 +2626,7 @@ void CConnman::SocketHandlerConnected(const std::set<SOCKET>& recv_set,
// receiving data. This means properly utilizing TCP flow control signalling.
// * Otherwise, if there is space left in the receive buffer (!fPauseRecv), try
// 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);
const bool queue_is_empty{to_send.empty() && !more};
if (!it->second->fPauseRecv && !it->second->fDisconnect && queue_is_empty) {
if (!it->second->fPauseRecv && !it->second->fDisconnect && it->second->nSendMsgSize == 0) {
it->second->AddRef();
vReceivableNodes.emplace(it->second);
}
Expand Down

0 comments on commit d1fce0b

Please sign in to comment.