From 4bc6ee10885d2e47d7cb1a5e7bf0d7a5251a75f7 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 1 May 2017 11:50:52 +0200 Subject: [PATCH] gossip: Fix two bugs in the forwarding of gossip We were using an uninitialized `broadcast_index` on the peer which would occasionally result in no forwardings at all, segmenting the network. And during the `msg_queue` refactor, some wait targets were not updated, resulting in the waits never to be woken up. --- lightningd/gossip/gossip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lightningd/gossip/gossip.c b/lightningd/gossip/gossip.c index ceff61f5b..3fcb66293 100644 --- a/lightningd/gossip/gossip.c +++ b/lightningd/gossip/gossip.c @@ -107,6 +107,7 @@ static struct peer *setup_new_peer(struct daemon *daemon, const u8 *msg) peer->error = NULL; peer->local = true; peer->num_pings_outstanding = 0; + peer->broadcast_index = 0; msg_queue_init(&peer->peer_out, peer); list_add_tail(&daemon->peers, &peer->list); tal_add_destructor(peer, destroy_peer); @@ -362,13 +363,15 @@ static struct io_plan *nonlocal_dump_gossip(struct io_conn *conn, struct daemon_ /* Make sure we are not connected directly */ if (peer->local) - return io_out_wait(conn, peer, daemon_conn_write_next, dc); + return msg_queue_wait(conn, &peer->owner_conn.out, + daemon_conn_write_next, dc); next = next_broadcast_message(peer->daemon->rstate->broadcasts, &peer->broadcast_index); if (!next) { - return io_out_wait(conn, peer, daemon_conn_write_next, dc); + return msg_queue_wait(conn, &peer->owner_conn.out, + daemon_conn_write_next, dc); } else { return io_write_wire(conn, next->payload, nonlocal_dump_gossip, dc); }