Skip to content

Commit

Permalink
connectd: clean up the channel stuffs when we get a reconnect
Browse files Browse the repository at this point in the history
If they've disconnected/reconnected we need to terminate all the
inflight stuff, plus go ahead and call 'disconnect' plugin trigger etc.
  • Loading branch information
niftynei committed Mar 5, 2021
1 parent 36460c9 commit 913252d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 4 additions & 3 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions lightningd/dual_open_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 913252d

Please sign in to comment.