openingd: prioritize incoming peer traffic over handling (and sending out) gossip

- reduces probability for a deadlock where we block on sending data because
  the other peer cannot receive because it blocks on sending data etc.
- when either side sends so much data that it fills up the kernel/network buffer
- however sending out gossip can still block when (malicious) peer never receives
This commit is contained in:
Simon Vrouwe 2018-09-17 08:55:30 +03:00 committed by Rusty Russell
parent 674d176087
commit 94e42f2384

View file

@ -1157,10 +1157,11 @@ int main(int argc, char *argv[])
* don't try to service more than one fd per loop. */
if (pollfd[0].revents & POLLIN)
msg = handle_master_in(state);
else if (pollfd[1].revents & POLLIN)
handle_gossip_in(state);
else if (pollfd[2].revents & POLLIN)
msg = handle_peer_in(state);
else if (pollfd[1].revents & POLLIN)
handle_gossip_in(state);
clean_tmpctx();
}