mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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>
This commit is contained in:
@@ -23,8 +23,7 @@ static bool connects_to_peer(struct subd *owner)
|
|||||||
return owner && owner->talks_to_peer;
|
return owner && owner->talks_to_peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void channel_set_owner(struct channel *channel, struct subd *owner,
|
void channel_set_owner(struct channel *channel, struct subd *owner)
|
||||||
bool reconnect)
|
|
||||||
{
|
{
|
||||||
struct subd *old_owner = channel->owner;
|
struct subd *old_owner = channel->owner;
|
||||||
channel->owner = owner;
|
channel->owner = owner;
|
||||||
@@ -46,12 +45,6 @@ void channel_set_owner(struct channel *channel, struct subd *owner,
|
|||||||
take(msg));
|
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);
|
channel->connected = connects_to_peer(owner);
|
||||||
}
|
}
|
||||||
@@ -105,7 +98,7 @@ static void destroy_channel(struct channel *channel)
|
|||||||
htlc_state_name(hin->hstate));
|
htlc_state_name(hin->hstate));
|
||||||
|
|
||||||
/* Free any old owner still hanging around. */
|
/* 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);
|
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->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 non-cooperatively (unilateral) to chain. */
|
||||||
drop_to_chain(ld, channel, false);
|
drop_to_chain(ld, channel, false);
|
||||||
|
|
||||||
@@ -446,5 +439,9 @@ void channel_fail_transient(struct channel *channel, const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
#endif
|
#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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ void delete_channel(struct channel *channel);
|
|||||||
const char *channel_state_name(const struct channel *channel);
|
const char *channel_state_name(const struct channel *channel);
|
||||||
const char *channel_state_str(enum channel_state state);
|
const char *channel_state_str(enum channel_state state);
|
||||||
|
|
||||||
void channel_set_owner(struct channel *channel, struct subd *owner,
|
void channel_set_owner(struct channel *channel, struct subd *owner);
|
||||||
bool reconnect);
|
|
||||||
|
|
||||||
/* Channel has failed, but can try again. */
|
/* Channel has failed, but can try again. */
|
||||||
PRINTF_FMT(2,3) void channel_fail_transient(struct channel *channel,
|
PRINTF_FMT(2,3) void channel_fail_transient(struct channel *channel,
|
||||||
|
|||||||
@@ -312,8 +312,7 @@ void peer_start_channeld(struct channel *channel,
|
|||||||
take(&pps->peer_fd),
|
take(&pps->peer_fd),
|
||||||
take(&pps->gossip_fd),
|
take(&pps->gossip_fd),
|
||||||
take(&pps->gossip_store_fd),
|
take(&pps->gossip_store_fd),
|
||||||
take(&hsmfd), NULL),
|
take(&hsmfd), NULL));
|
||||||
false);
|
|
||||||
|
|
||||||
if (!channel->owner) {
|
if (!channel->owner) {
|
||||||
log_unusual(channel->log, "Could not subdaemon channel: %s",
|
log_unusual(channel->log, "Could not subdaemon channel: %s",
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ static void peer_closing_complete(struct channel *channel, const u8 *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Don't report spurious failure when closingd exits. */
|
/* Don't report spurious failure when closingd exits. */
|
||||||
channel_set_owner(channel, NULL, false);
|
channel_set_owner(channel, NULL);
|
||||||
/* Clear any transient negotiation messages */
|
/* Clear any transient negotiation messages */
|
||||||
channel_set_billboard(channel, false, NULL);
|
channel_set_billboard(channel, false, NULL);
|
||||||
|
|
||||||
@@ -186,8 +186,7 @@ void peer_start_closingd(struct channel *channel,
|
|||||||
take(&pps->gossip_fd),
|
take(&pps->gossip_fd),
|
||||||
take(&pps->gossip_store_fd),
|
take(&pps->gossip_store_fd),
|
||||||
take(&hsmfd),
|
take(&hsmfd),
|
||||||
NULL),
|
NULL));
|
||||||
false);
|
|
||||||
|
|
||||||
if (!channel->owner) {
|
if (!channel->owner) {
|
||||||
log_unusual(channel->log, "Could not subdaemon closing: %s",
|
log_unusual(channel->log, "Could not subdaemon closing: %s",
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ static enum watch_result onchain_tx_watched(struct lightningd *ld,
|
|||||||
|
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
log_unusual(channel->log, "Chain reorganization!");
|
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 */
|
/* We will most likely be freed, so this is a noop */
|
||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
@@ -421,7 +421,7 @@ static void onchain_error(struct channel *channel,
|
|||||||
/* FIXME: re-launch? */
|
/* FIXME: re-launch? */
|
||||||
log_broken(channel->log, "%s", desc);
|
log_broken(channel->log, "%s", desc);
|
||||||
channel_set_billboard(channel, true, 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
|
/* 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,
|
onchain_error,
|
||||||
channel_set_billboard,
|
channel_set_billboard,
|
||||||
take(&hsmfd),
|
take(&hsmfd),
|
||||||
NULL),
|
NULL));
|
||||||
false);
|
|
||||||
|
|
||||||
if (!channel->owner) {
|
if (!channel->owner) {
|
||||||
log_broken(channel->log, "Could not subdaemon onchain: %s",
|
log_broken(channel->log, "Could not subdaemon onchain: %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user