Skip to content

Commit

Permalink
lightningd: pass disconnect flag to subd's errcb.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Oct 23, 2023
1 parent 443082b commit 9abf9c2
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
14 changes: 7 additions & 7 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -3677,9 +3677,9 @@ AUTODATA(json_command, &openchannel_abort_command);
static void dualopen_errmsg(struct channel *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them)
const u8 *err_for_them,
bool disconnect,
bool warning)
{
/* Clean up any in-progress open attempts */
channel_cleanup_commands(channel, desc);
Expand All @@ -3694,7 +3694,7 @@ static void dualopen_errmsg(struct channel *channel,
/* No peer_fd means a subd crash or disconnection. */
if (!peer_fd) {
/* If the channel is unsaved, we forget it */
channel_fail_transient(channel, true, "%s: %s",
channel_fail_transient(channel, disconnect, "%s: %s",
channel->owner->name, desc);
return;
}
Expand All @@ -3707,14 +3707,14 @@ static void dualopen_errmsg(struct channel *channel,
* surprisingly, they now spew out spurious errors frequently,
* and we would close the channel on them. We now support warnings
* for this case. */
if (warning || aborted) {
if (warning || !disconnect) {
/* We *don't* hang up if they aborted: that's fine! */
channel_fail_transient(channel, !aborted, "%s %s: %s",
channel_fail_transient(channel, disconnect, "%s %s: %s",
channel->owner->name,
warning ? "WARNING" : "ABORTED",
desc);

if (aborted) {
if (!disconnect) {
char *err = restart_dualopend(tmpctx,
channel->peer->ld,
channel, true);
Expand Down
6 changes: 3 additions & 3 deletions lightningd/onchain_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,9 +1496,9 @@ static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds U
static void onchain_error(struct channel *channel,
struct peer_fd *pps UNUSED,
const char *desc,
bool warning UNUSED,
bool aborted UNUSED,
const u8 *err_for_them UNUSED)
const u8 *err_for_them UNUSED,
bool disconnect UNUSED,
bool warning UNUSED)
{
channel_set_owner(channel, NULL);

Expand Down
6 changes: 3 additions & 3 deletions lightningd/opening_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ new_uncommitted_channel(struct peer *peer)
void opend_channel_errmsg(struct uncommitted_channel *uc,
struct peer_fd *peer_fd,
const char *desc,
bool warning UNUSED,
bool aborted UNUSED,
const u8 *err_for_them UNUSED)
const u8 *err_for_them UNUSED,
bool disconnect UNUSED,
bool warning UNUSED)
{
/* Close fds, if any. */
tal_free(peer_fd);
Expand Down
6 changes: 3 additions & 3 deletions lightningd/opening_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct uncommitted_channel *new_uncommitted_channel(struct peer *peer);
void opend_channel_errmsg(struct uncommitted_channel *uc,
struct peer_fd *peer_fd,
const char *desc,
bool warning UNUSED,
bool aborted UNUSED,
const u8 *err_for_them UNUSED);
const u8 *err_for_them UNUSED,
bool disconnect UNUSED,
bool warning UNUSED);

void opend_channel_set_billboard(struct uncommitted_channel *uc,
bool perm UNUSED,
Expand Down
12 changes: 6 additions & 6 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ void resend_closing_transactions(struct lightningd *ld)
void channel_errmsg(struct channel *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted UNUSED,
const u8 *err_for_them)
const u8 *err_for_them,
bool disconnect,
bool warning)
{
/* Clean up any in-progress open attempts */
channel_cleanup_commands(channel, desc);
Expand All @@ -458,7 +458,7 @@ void channel_errmsg(struct channel *channel,
/* No peer_fd means a subd crash or disconnection. */
if (!peer_fd) {
/* If the channel is unsaved, we forget it */
channel_fail_transient(channel, true, "%s: %s",
channel_fail_transient(channel, disconnect, "%s: %s",
channel->owner->name, desc);
return;
}
Expand All @@ -472,7 +472,7 @@ void channel_errmsg(struct channel *channel,
* would recover after a reconnect. So we downgrade, but snark
* about it in the logs. */
if (!err_for_them && strends(desc, "internal error")) {
channel_fail_transient(channel, true, "%s: %s",
channel_fail_transient(channel, disconnect, "%s: %s",
channel->owner->name,
"lnd sent 'internal error':"
" let's give it some space");
Expand All @@ -481,7 +481,7 @@ void channel_errmsg(struct channel *channel,

/* This is us, sending a warning. */
if (warning) {
channel_fail_transient(channel, true, "%s sent %s",
channel_fail_transient(channel, disconnect, "%s sent %s",
channel->owner->name,
desc);
return;
Expand Down
6 changes: 3 additions & 3 deletions lightningd/peer_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void peer_spoke(struct lightningd *ld, const u8 *msg);
void channel_errmsg(struct channel *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them);
const u8 *err_for_them,
bool disconnect,
bool warning);

u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx);
u8 *p2tr_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx);
Expand Down
14 changes: 7 additions & 7 deletions lightningd/subd.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[1])

/* Don't free sd; we may be about to free channel. */
sd->channel = NULL;
sd->errcb(channel, peer_fd, desc, warning, !disconnect, err_for_them);
sd->errcb(channel, peer_fd, desc, err_for_them, disconnect, warning);
return true;
}

Expand Down Expand Up @@ -709,9 +709,9 @@ static struct subd *new_subd(const tal_t *ctx,
void (*errcb)(void *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them),
const u8 *err_for_them,
bool disconnect,
bool warning),
void (*billboardcb)(void *channel,
bool perm,
const char *happenings),
Expand Down Expand Up @@ -815,9 +815,9 @@ struct subd *new_channel_subd_(const tal_t *ctx,
void (*errcb)(void *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them),
const u8 *err_for_them,
bool disconnect,
bool warning),
void (*billboardcb)(void *channel, bool perm,
const char *happenings),
...)
Expand Down
14 changes: 7 additions & 7 deletions lightningd/subd.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ struct subd {
void (*errcb)(void *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them);
const u8 *err_for_them,
bool disconnect,
bool warning);

/* Callback to display information for listpeers RPC */
void (*billboardcb)(void *channel, bool perm, const char *happenings);
Expand Down Expand Up @@ -134,9 +134,9 @@ struct subd *new_channel_subd_(const tal_t *ctx,
void (*errcb)(void *channel,
struct peer_fd *peer_fd,
const char *desc,
bool warning,
bool aborted,
const u8 *err_for_them),
const u8 *err_for_them,
bool disconnect,
bool warning),
void (*billboardcb)(void *channel, bool perm,
const char *happenings),
...);
Expand All @@ -150,7 +150,7 @@ struct subd *new_channel_subd_(const tal_t *ctx,
typesafe_cb_postargs(void, void *, (errcb), \
(channel), \
struct peer_fd *, \
const char *, bool, bool, const u8 *), \
const char *, const u8 *, bool, bool), \
typesafe_cb_postargs(void, void *, (billboardcb), \
(channel), bool, \
const char *), \
Expand Down

0 comments on commit 9abf9c2

Please sign in to comment.