From 87effd90c21beca8fca375668114306915e74a97 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Mar 2018 02:13:55 +1030 Subject: [PATCH] gossipd: Revert 6afc7dcc09cb3fafb5f1d81cbb5b0f95c3c8bb88. This bandaid was solved properly by 94711969f9a5f57a99365fa71f579a42bbc75e47 where other daemons say where they were up to. Signed-off-by: Rusty Russell --- gossipd/broadcast.c | 5 +++-- gossipd/broadcast.h | 3 ++- gossipd/gossip.c | 24 ++++-------------------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/gossipd/broadcast.c b/gossipd/broadcast.c index 91c449eba..fd6b9ab85 100644 --- a/gossipd/broadcast.c +++ b/gossipd/broadcast.c @@ -49,9 +49,10 @@ bool replace_broadcast(const tal_t *ctx, return evicted; } -struct queued_message *next_broadcast_message(struct broadcast_state *bstate, u64 last_index) +struct queued_message *next_broadcast_message(struct broadcast_state *bstate, + u64 *last_index) { - return uintmap_after(&bstate->broadcasts, &last_index); + return uintmap_after(&bstate->broadcasts, last_index); } const u8 *get_broadcast(struct broadcast_state *bstate, u64 msgidx) diff --git a/gossipd/broadcast.h b/gossipd/broadcast.h index ef00f456f..5deb7c335 100644 --- a/gossipd/broadcast.h +++ b/gossipd/broadcast.h @@ -34,7 +34,8 @@ bool replace_broadcast(const tal_t *ctx, const u8 *payload TAKES); -struct queued_message *next_broadcast_message(struct broadcast_state *bstate, u64 last_index); +struct queued_message *next_broadcast_message(struct broadcast_state *bstate, + u64 *last_index); const u8 *get_broadcast(struct broadcast_state *bstate, u64 msgidx); #endif /* LIGHTNING_LIGHTNINGD_GOSSIP_BROADCAST_H */ diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 75051fe1b..d27e9cdb4 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -690,13 +690,6 @@ static void wake_pkt_out(struct peer *peer) /* Mutual recursion. */ static struct io_plan *peer_pkt_out(struct io_conn *conn, struct peer *peer); -static struct io_plan *local_gossip_broadcast_done(struct io_conn *conn, - struct peer *peer) -{ - peer->broadcast_index++; - return peer_pkt_out(conn, peer); -} - static struct io_plan *peer_pkt_out(struct io_conn *conn, struct peer *peer) { /* First priority is queued packets, if any */ @@ -719,12 +712,12 @@ static struct io_plan *peer_pkt_out(struct io_conn *conn, struct peer *peer) struct queued_message *next; next = next_broadcast_message(peer->daemon->rstate->broadcasts, - peer->broadcast_index); + &peer->broadcast_index); if (next) return peer_write_message(conn, &peer->local->pcs, next->payload, - local_gossip_broadcast_done); + peer_pkt_out); /* Gossip is drained. Wait for next timer. */ peer->gossip_sync = false; @@ -916,15 +909,6 @@ static bool send_peer_with_fds(struct peer *peer, const u8 *msg) return true; } -static struct io_plan *nonlocal_gossip_broadcast_done(struct io_conn *conn, - struct daemon_conn *dc) -{ - struct peer *peer = dc->ctx; - - peer->broadcast_index++; - return nonlocal_dump_gossip(conn, dc); -} - /** * nonlocal_dump_gossip - catch the nonlocal peer up with the latest gossip. * @@ -945,7 +929,7 @@ static struct io_plan *nonlocal_dump_gossip(struct io_conn *conn, struct daemon_ daemon_conn_write_next, dc); next = next_broadcast_message(peer->daemon->rstate->broadcasts, - peer->broadcast_index); + &peer->broadcast_index); if (!next) { peer->gossip_sync = false; @@ -956,7 +940,7 @@ static struct io_plan *nonlocal_dump_gossip(struct io_conn *conn, struct daemon_ peer->broadcast_index, next->payload); return io_write_wire(conn, take(msg), - nonlocal_gossip_broadcast_done, dc); + nonlocal_dump_gossip, dc); } }