File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1425,6 +1425,9 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
1425
1425
// write buffer in this case before receiving more. This avoids
1426
1426
// needlessly queueing received data, if the remote peer is not themselves
1427
1427
// 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.
1428
1431
// * Otherwise, if there is space left in the receive buffer, select() for
1429
1432
// receiving data.
1430
1433
// * Hand off all complete messages to the processor, to be handled without
@@ -1445,7 +1448,9 @@ bool CConnman::GenerateSelectSet(const std::vector<CNode*>& nodes,
1445
1448
error_set.insert (pnode->m_sock ->Get ());
1446
1449
if (select_send) {
1447
1450
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 ;
1449
1454
}
1450
1455
if (select_recv) {
1451
1456
recv_set.insert (pnode->m_sock ->Get ());
Original file line number Diff line number Diff line change @@ -313,6 +313,8 @@ class CNetMessage {
313
313
*/
314
314
class TransportDeserializer {
315
315
public:
316
+ // returns true if the current deserialization is empty
317
+ virtual bool IsEmpty () const = 0;
316
318
// returns true if the current deserialization is complete
317
319
virtual bool Complete () const = 0;
318
320
// set the serialization context version
@@ -363,6 +365,10 @@ class V1TransportDeserializer final : public TransportDeserializer
363
365
Reset ();
364
366
}
365
367
368
+ bool IsEmpty () const override
369
+ {
370
+ return (nHdrPos == 0 );
371
+ }
366
372
bool Complete () const override
367
373
{
368
374
if (!in_data)
You can’t perform that action at this time.
0 commit comments