lightningd: don't tell connectd to disconnect peer if it told us.

We allow connectd to tell us a peer has gone away, but now we need
to make sure we don't double-spiderman and tell it to disconnect peer.

This is particularly harmful on reconnect: it (will soon) tell us the
old connection is gone, ready to tell us the new peer has connected.
We would tell it to disconnect the peer, which throws away the new
connection!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-16 14:19:30 +09:30 committed by neil saitug
parent c64ce4bbf3
commit d58e6fa20b
1 changed files with 5 additions and 2 deletions

View File

@ -668,8 +668,11 @@ void maybe_disconnect_peer(struct lightningd *ld, struct peer *peer)
return;
}
subd_send_msg(ld->connectd,
take(towire_connectd_discard_peer(NULL, &peer->id)));
/* If connectd was the one who told us to cleanup peer, don't
* tell it to discard again: it might have reconnected! */
if (peer->is_connected)
subd_send_msg(ld->connectd,
take(towire_connectd_discard_peer(NULL, &peer->id)));
}
static struct command_result *json_sendcustommsg(struct command *cmd,