Skip to content

Commit

Permalink
Merge branch 'master-fix-stall' into elements-22-fix-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
psgreco committed Apr 17, 2023
2 parents b37e09c + b2ce24c commit 9ef0265
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,9 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
// write buffer in this case before receiving more. This avoids
// needlessly queueing received data, if the remote peer is not themselves
// receiving data. This means properly utilizing TCP flow control signalling.
// This logic can put both nodes in deadlock if they are both "not receiving",
// so there is a special case where we only stop receiving new messages, but
// keep processing the in-progress ones.
// * Otherwise, if there is space left in the receive buffer, select() for
// receiving data.
// * Hand off all complete messages to the processor, to be handled without
Expand All @@ -1380,7 +1383,9 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
error_set.insert(pnode->hSocket);
if (select_send) {
send_set.insert(pnode->hSocket);
continue;
// Only stop receiving new messages, but keep processing incomplete ones
if (!pnode->m_deserializer->IsEmpty())
continue;
}
if (select_recv) {
recv_set.insert(pnode->hSocket);
Expand Down
6 changes: 6 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ class CNetMessage {
*/
class TransportDeserializer {
public:
// returns true if the current deserialization is empty
virtual bool IsEmpty() const = 0;
// returns true if the current deserialization is complete
virtual bool Complete() const = 0;
// set the serialization context version
Expand Down Expand Up @@ -352,6 +354,10 @@ class V1TransportDeserializer final : public TransportDeserializer
Reset();
}

bool IsEmpty() const override
{
return (nHdrPos == 0);
}
bool Complete() const override
{
if (!in_data)
Expand Down

0 comments on commit 9ef0265

Please sign in to comment.