File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1361,6 +1361,9 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
1361
1361
// write buffer in this case before receiving more. This avoids
1362
1362
// needlessly queueing received data, if the remote peer is not themselves
1363
1363
// receiving data. This means properly utilizing TCP flow control signalling.
1364
+ // This logic can put both nodes in deadlock if they are both "not receiving",
1365
+ // so there is a special case where we only stop receiving new messages, but
1366
+ // keep processing the in-progress ones.
1364
1367
// * Otherwise, if there is space left in the receive buffer, select() for
1365
1368
// receiving data.
1366
1369
// * Hand off all complete messages to the processor, to be handled without
@@ -1380,7 +1383,9 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
1380
1383
error_set.insert (pnode->hSocket );
1381
1384
if (select_send) {
1382
1385
send_set.insert (pnode->hSocket );
1383
- continue ;
1386
+ // Only stop receiving new messages, but keep processing incomplete ones
1387
+ if (!pnode->m_deserializer ->IsEmpty ())
1388
+ continue ;
1384
1389
}
1385
1390
if (select_recv) {
1386
1391
recv_set.insert (pnode->hSocket );
Original file line number Diff line number Diff line change @@ -302,6 +302,8 @@ class CNetMessage {
302
302
*/
303
303
class TransportDeserializer {
304
304
public:
305
+ // returns true if the current deserialization is empty
306
+ virtual bool IsEmpty () const = 0;
305
307
// returns true if the current deserialization is complete
306
308
virtual bool Complete () const = 0;
307
309
// set the serialization context version
@@ -352,6 +354,10 @@ class V1TransportDeserializer final : public TransportDeserializer
352
354
Reset ();
353
355
}
354
356
357
+ bool IsEmpty () const override
358
+ {
359
+ return (nHdrPos == 0 );
360
+ }
355
361
bool Complete () const override
356
362
{
357
363
if (!in_data)
You can’t perform that action at this time.
0 commit comments