From 8cc29198849c6102c116fa4e2b11f80990a001e4 Mon Sep 17 00:00:00 2001 From: niftynei Date: Fri, 5 Mar 2021 12:39:05 -0600 Subject: [PATCH] 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. --- lightningd/connect_control.c | 4 +++- lightningd/dual_open_control.c | 7 ++++--- lightningd/dual_open_control.h | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index ca0be21d4..98f6878f6 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -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 */ diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 94e8b0426..385720365 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -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; diff --git a/lightningd/dual_open_control.h b/lightningd/dual_open_control.h index c559a5003..8c82ce21a 100644 --- a/lightningd/dual_open_control.h +++ b/lightningd/dual_open_control.h @@ -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 */