lightningd: clean up subds before freeing HTLCs.

Otherwise we get weird effects, as htlcs are being freed:

```
2022-01-26T05:07:37.8774610Z lightningd-1: 2022-01-26T04:47:48.770Z DEBUG   030eeb52087b9dbb27b7aec79ca5249369f6ce7b20a5684ce38d9f4595a21c2fda-chan#8: Failing HTLC 18446744073709551615 due to peer death
2022-01-26T05:07:37.8775287Z lightningd-1: 2022-01-26T04:47:48.770Z **BROKEN** 030eeb52087b9dbb27b7aec79ca5249369f6ce7b20a5684ce38d9f4595a21c2fda-chan#8: Neither origin nor in?
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-01-30 14:07:30 +10:30
parent d370aac020
commit 0c24334738
5 changed files with 42 additions and 5 deletions

View File

@@ -570,10 +570,15 @@ static void onchain_error(struct channel *channel,
bool warning UNUSED,
const u8 *err_for_them UNUSED)
{
channel_set_owner(channel, NULL);
/* This happens on shutdown: fine */
if (channel->peer->ld->state == LD_STATE_SHUTDOWN)
return;
/* FIXME: re-launch? */
log_broken(channel->log, "%s", desc);
channel_set_billboard(channel, true, desc);
channel_set_owner(channel, NULL);
}
/* With a reorg, this can get called multiple times; each time we'll kill