mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +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:
committed by
Rusty Russell
parent
f61da7eb64
commit
4bc6ee1088
@@ -107,6 +107,7 @@ static struct peer *setup_new_peer(struct daemon *daemon, const u8 *msg)
|
|||||||
peer->error = NULL;
|
peer->error = NULL;
|
||||||
peer->local = true;
|
peer->local = true;
|
||||||
peer->num_pings_outstanding = 0;
|
peer->num_pings_outstanding = 0;
|
||||||
|
peer->broadcast_index = 0;
|
||||||
msg_queue_init(&peer->peer_out, peer);
|
msg_queue_init(&peer->peer_out, peer);
|
||||||
list_add_tail(&daemon->peers, &peer->list);
|
list_add_tail(&daemon->peers, &peer->list);
|
||||||
tal_add_destructor(peer, destroy_peer);
|
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 */
|
/* Make sure we are not connected directly */
|
||||||
if (peer->local)
|
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,
|
next = next_broadcast_message(peer->daemon->rstate->broadcasts,
|
||||||
&peer->broadcast_index);
|
&peer->broadcast_index);
|
||||||
|
|
||||||
if (!next) {
|
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 {
|
} else {
|
||||||
return io_write_wire(conn, next->payload, nonlocal_dump_gossip, dc);
|
return io_write_wire(conn, next->payload, nonlocal_dump_gossip, dc);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user