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 @@ -1361,6 +1361,9 @@ bool CConnman::GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &s
13611361 // write buffer in this case before receiving more. This avoids
13621362 // needlessly queueing received data, if the remote peer is not themselves
13631363 // 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.
13641367 // * Otherwise, if there is space left in the receive buffer, select() for
13651368 // receiving data.
13661369 // * 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
13801383 error_set.insert (pnode->hSocket );
13811384 if (select_send) {
13821385 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 ;
13841389 }
13851390 if (select_recv) {
13861391 recv_set.insert (pnode->hSocket );
Original file line number Diff line number Diff line change @@ -302,6 +302,8 @@ class CNetMessage {
302302 */
303303class TransportDeserializer {
304304public:
305+ // returns true if the current deserialization is empty
306+ virtual bool IsEmpty () const = 0;
305307 // returns true if the current deserialization is complete
306308 virtual bool Complete () const = 0;
307309 // set the serialization context version
@@ -352,6 +354,10 @@ class V1TransportDeserializer final : public TransportDeserializer
352354 Reset ();
353355 }
354356
357+ bool IsEmpty () const override
358+ {
359+ return (nHdrPos == 0 );
360+ }
355361 bool Complete () const override
356362 {
357363 if (!in_data)
You can’t perform that action at this time.
0 commit comments