Browse Source

lightningd: make callers of channel_set_owner do reconnection.

There's only one caller which used the flag.

As a side-effect, now we'll try reconnect even if the previous owner
was NULL (which mainly effects the case where we couldn't create the subd).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2938/head
Rusty Russell 6 years ago
parent
commit
fea7e10e15
  1. 19
      lightningd/channel.c
  2. 3
      lightningd/channel.h
  3. 3
      lightningd/channel_control.c
  4. 5
      lightningd/closing_control.c
  5. 7
      lightningd/onchain_control.c

19
lightningd/channel.c

@ -23,8 +23,7 @@ static bool connects_to_peer(struct subd *owner)
return owner && owner->talks_to_peer;
}
void channel_set_owner(struct channel *channel, struct subd *owner,
bool reconnect)
void channel_set_owner(struct channel *channel, struct subd *owner)
{
struct subd *old_owner = channel->owner;
channel->owner = owner;
@ -46,12 +45,6 @@ void channel_set_owner(struct channel *channel, struct subd *owner,
take(msg));
}
}
if (reconnect) {
/* Reconnect after 1 second: prevents some spurious
* reconnects during tests. */
delay_then_reconnect(channel, 1, &channel->peer->addr);
}
}
channel->connected = connects_to_peer(owner);
}
@ -105,7 +98,7 @@ static void destroy_channel(struct channel *channel)
htlc_state_name(hin->hstate));
/* Free any old owner still hanging around. */
channel_set_owner(channel, NULL, false);
channel_set_owner(channel, NULL);
list_del_from(&channel->peer->channels, &channel->list);
}
@ -379,7 +372,7 @@ void channel_fail_permanent(struct channel *channel, const char *fmt, ...)
channel->error = towire_errorfmt(channel, &cid, "%s", why);
}
channel_set_owner(channel, NULL, false);
channel_set_owner(channel, NULL);
/* Drop non-cooperatively (unilateral) to chain. */
drop_to_chain(ld, channel, false);
@ -446,5 +439,9 @@ void channel_fail_transient(struct channel *channel, const char *fmt, ...)
}
#endif
channel_set_owner(channel, NULL, true);
channel_set_owner(channel, NULL);
/* Reconnect after 1 second: prevents some spurious reconnects
* during tests. */
delay_then_reconnect(channel, 1, &channel->peer->addr);
}

3
lightningd/channel.h

@ -172,8 +172,7 @@ void delete_channel(struct channel *channel);
const char *channel_state_name(const struct channel *channel);
const char *channel_state_str(enum channel_state state);
void channel_set_owner(struct channel *channel, struct subd *owner,
bool reconnect);
void channel_set_owner(struct channel *channel, struct subd *owner);
/* Channel has failed, but can try again. */
PRINTF_FMT(2,3) void channel_fail_transient(struct channel *channel,

3
lightningd/channel_control.c

@ -312,8 +312,7 @@ void peer_start_channeld(struct channel *channel,
take(&pps->peer_fd),
take(&pps->gossip_fd),
take(&pps->gossip_store_fd),
take(&hsmfd), NULL),
false);
take(&hsmfd), NULL));
if (!channel->owner) {
log_unusual(channel->log, "Could not subdaemon channel: %s",

5
lightningd/closing_control.c

@ -116,7 +116,7 @@ static void peer_closing_complete(struct channel *channel, const u8 *msg)
}
/* Don't report spurious failure when closingd exits. */
channel_set_owner(channel, NULL, false);
channel_set_owner(channel, NULL);
/* Clear any transient negotiation messages */
channel_set_billboard(channel, false, NULL);
@ -186,8 +186,7 @@ void peer_start_closingd(struct channel *channel,
take(&pps->gossip_fd),
take(&pps->gossip_store_fd),
take(&hsmfd),
NULL),
false);
NULL));
if (!channel->owner) {
log_unusual(channel->log, "Could not subdaemon closing: %s",

7
lightningd/onchain_control.c

@ -102,7 +102,7 @@ static enum watch_result onchain_tx_watched(struct lightningd *ld,
if (depth == 0) {
log_unusual(channel->log, "Chain reorganization!");
channel_set_owner(channel, NULL, false);
channel_set_owner(channel, NULL);
/* We will most likely be freed, so this is a noop */
return KEEP_WATCHING;
@ -421,7 +421,7 @@ static void onchain_error(struct channel *channel,
/* FIXME: re-launch? */
log_broken(channel->log, "%s", desc);
channel_set_billboard(channel, true, desc);
channel_set_owner(channel, NULL, false);
channel_set_owner(channel, NULL);
}
/* With a reorg, this can get called multiple times; each time we'll kill
@ -457,8 +457,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
onchain_error,
channel_set_billboard,
take(&hsmfd),
NULL),
false);
NULL));
if (!channel->owner) {
log_broken(channel->log, "Could not subdaemon onchain: %s",

Loading…
Cancel
Save