Browse Source

channeld: prioritize read from peer over (read from gossipd and) write to peer

This solves (or at least reduces probability of) a deadlock in channeld
when there is lot of gossip traffic, see issue #2286. That issue is
almost identical to #1943 (deadlock in openingd) and so is the fix.
sanitizers
Simon Vrouwe 6 years ago
committed by Christian Decker
parent
commit
6e4d9acac3
  1. 8
      channeld/channeld.c

8
channeld/channeld.c

@ -2928,6 +2928,10 @@ int main(int argc, char *argv[])
"Can't read command: %s",
strerror(errno));
req_in(peer, msg);
} else if (FD_ISSET(PEER_FD, &rfds)) {
/* This could take forever, but who cares? */
msg = sync_crypto_read(tmpctx, &peer->cs, PEER_FD);
peer_in(peer, msg);
} else if (FD_ISSET(GOSSIP_FD, &rfds)) {
msg = wire_sync_read(tmpctx, GOSSIP_FD);
/* Gossipd hangs up on us to kill us when a new
@ -2935,10 +2939,6 @@ int main(int argc, char *argv[])
if (!msg)
peer_failed_connection_lost();
handle_gossip_msg(PEER_FD, &peer->cs, take(msg));
} else if (FD_ISSET(PEER_FD, &rfds)) {
/* This could take forever, but who cares? */
msg = sync_crypto_read(tmpctx, &peer->cs, PEER_FD);
peer_in(peer, msg);
}
}

Loading…
Cancel
Save