mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
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.
This commit is contained in:
parent
f61da7eb64
commit
4bc6ee1088
1 changed files with 5 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue