Browse Source

master: Don't crash if peer reconnects before we activate it

`activate_peer` does little more than wiring up some txwatches and
asking `gossipd` to reconnect to the peer. If the peer manages to
reconnect before we activate then we would crash.

This just changes the `assert` causing the crash into a conditional
whether we need to reconnect or not.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
e04619457b
  1. 7
      lightningd/peer_control.c

7
lightningd/peer_control.c

@ -2789,8 +2789,6 @@ static void activate_peer(struct peer *peer)
{
u8 *msg;
assert(!peer->owner);
/* Pass gossipd any addrhints we currently have */
msg = towire_gossipctl_peer_addrhint(peer, &peer->id, &peer->addr);
subd_send_msg(peer->ld->gossip, take(msg));
@ -2809,7 +2807,10 @@ static void activate_peer(struct peer *peer)
watch_txo(peer, peer->ld->topology, peer, peer->funding_txid, peer->funding_outnum,
funding_spent, NULL);
if (peer_wants_reconnect(peer)) {
/* If peer->owner then we had a reconnect while loading and
* activating the peers, don't ask gossipd to connect in that
* case */
if (!peer->owner && peer_wants_reconnect(peer)) {
msg = towire_gossipctl_reach_peer(peer, &peer->id);
subd_send_msg(peer->ld->gossip, take(msg));
}

Loading…
Cancel
Save