File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1425,6 +1425,9 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
14251425 // write buffer in this case before receiving more. This avoids
14261426 // needlessly queueing received data, if the remote peer is not themselves
14271427 // receiving data. This means properly utilizing TCP flow control signalling.
1428+ // This logic can put both nodes in deadlock if they are both "not receiving",
1429+ // so there is a special case where we only stop receiving new messages, but
1430+ // keep processing the in-progress ones.
14281431 // * Otherwise, if there is space left in the receive buffer, select() for
14291432 // receiving data.
14301433 // * Hand off all complete messages to the processor, to be handled without
@@ -1445,7 +1448,9 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
14451448 error_set.insert (pnode->m_sock ->Get ());
14461449 if (select_send) {
14471450 send_set.insert (pnode->m_sock ->Get ());
1448- continue ;
1451+ // Only stop receiving new messages, but keep processing incomplete ones
1452+ if (pnode->m_deserializer ->IsEmpty ())
1453+ continue ;
14491454 }
14501455 if (select_recv) {
14511456 recv_set.insert (pnode->m_sock ->Get ());
Original file line number Diff line number Diff line change @@ -313,6 +313,8 @@ class CNetMessage {
313313 */
314314class TransportDeserializer {
315315public:
316+ // returns true if the current deserialization is empty
317+ virtual bool IsEmpty () const = 0;
316318 // returns true if the current deserialization is complete
317319 virtual bool Complete () const = 0;
318320 // set the serialization context version
@@ -363,6 +365,10 @@ class V1TransportDeserializer final : public TransportDeserializer
363365 Reset ();
364366 }
365367
368+ bool IsEmpty () const override
369+ {
370+ return (nHdrPos == 0 );
371+ }
366372 bool Complete () const override
367373 {
368374 if (!in_data)
You can’t perform that action at this time.
0 commit comments