connectd: clean up the channel stuffs when we get a reconnect

If they've disconnected/reconnected we need to terminate all the
inflight stuff, plus go ahead and call 'disconnect' plugin trigger etc.
This commit is contained in:
niftynei 2021-03-05 12:39:05 -06:00 committed by Rusty Russell
parent 97e64915c5
commit 8cc2919884
3 changed files with 10 additions and 4 deletions

View File

@ -283,8 +283,10 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
c = active_channel_by_id(ld, &id, &uc);
if (uc)
kill_uncommitted_channel(uc, "Reconnected");
else if (c)
else if (c) {
channel_cleanup_commands(c, "Reconnected");
channel_fail_reconnect(c, "Reconnected");
}
#if EXPERIMENTAL_FEATURES
else {
/* v2 has unsaved channels, not uncommitted_chans */

View File

@ -82,11 +82,12 @@ void channel_close_conn(struct channel *channel, const char *why)
channel_disconnect(channel, LOG_INFORM, false, why);
}
static void channel_close_reconn(struct channel *channel, const char *why)
void channel_close_reconn(struct channel *channel, const char *why)
{
/* Close dualopend */
/* Close the daemon */
if (channel->owner) {
log_info(channel->log, "Killing dualopend: %s", why);
log_info(channel->log, "Killing %s: %s",
channel->owner->name, why);
subd_release_channel(channel->owner, channel);
channel->owner = NULL;

View File

@ -23,6 +23,9 @@ void dualopen_tell_depth(struct subd *dualopend,
void channel_close_conn(struct channel *channel,
const char *why);
void channel_close_reconn(struct channel *channel,
const char *why);
void json_add_unsaved_channel(struct json_stream *response,
const struct channel *channel);
#endif /* LIGHTNING_LIGHTNINGD_DUAL_OPEN_CONTROL_H */