From d1fce0b7cabc2f73b6085f31532f655d827f4e53 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:12:00 +0000 Subject: [PATCH] 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. --- src/net.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index e39b089645..39b7f5a904 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2255,6 +2255,7 @@ bool CConnman::GenerateSelectSet(const std::vector& 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) { @@ -2625,9 +2626,7 @@ void CConnman::SocketHandlerConnected(const std::set& 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); }