From e04619457bf4d96aed57c233efb793443e7b50f9 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 7 Feb 2018 16:47:12 +0100 Subject: [PATCH] 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 --- lightningd/peer_control.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index d4e0afec9..352c361c7 100644 --- a/lightningd/peer_control.c +++ b/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)); }