From 94e42f2384d8e24ce8e181d05da97d795a03c3d6 Mon Sep 17 00:00:00 2001 From: Simon Vrouwe Date: Mon, 17 Sep 2018 08:55:30 +0300 Subject: [PATCH] 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 --- openingd/openingd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openingd/openingd.c b/openingd/openingd.c index b17e0eea3..dbcca1692 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -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(); }