From 913252dc47f252f7aba1c04f1b1f1ae5e440db29 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 | 5 +++-- lightningd/dual_open_control.c | 7 ++++--- lightningd/dual_open_control.h | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index ca0be21d4c2b..f6e569125f9c 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -283,8 +283,9 @@ 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) - channel_fail_reconnect(c, "Reconnected"); + else if (c) { + channel_close_reconn(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 94e8b0426352..385720365c2d 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 c559a5003aac..8c82ce21a3fc 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 */