From d9d762170a6ff8cb7f2cdc5cf60067615446d574 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 22 Nov 2018 12:47:29 +1030 Subject: [PATCH] memleak: don't get stuck if per-peer daemons die. Instead, continue with the next phase. I would guess this is the cause of timeouts under Travis. Signed-off-by: Rusty Russell --- lightningd/opening_control.c | 12 +++++++++++- lightningd/peer_control.c | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 6a4c375ff..a0e77b2c7 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -863,6 +863,13 @@ AUTODATA(json_command, &fund_channel_command); /* Indented to avoid include ordering check */ #include +static void opening_died_forget_memleak(struct subd *openingd, + struct command *cmd) +{ + /* FIXME: We ignore the remaining openingds in this case. */ + opening_memleak_done(cmd, NULL); +} + /* Mutual recursion */ static void opening_memleak_req_next(struct command *cmd, struct peer *prev); static void opening_memleak_req_done(struct subd *openingd, @@ -872,6 +879,7 @@ static void opening_memleak_req_done(struct subd *openingd, bool found_leak; struct uncommitted_channel *uc = openingd->channel; + tal_del_destructor2(openingd, opening_died_forget_memleak, cmd); if (!fromwire_opening_dev_memleak_reply(msg, &found_leak)) { command_fail(cmd, LIGHTNINGD, "Bad opening_dev_memleak"); return; @@ -898,11 +906,13 @@ static void opening_memleak_req_next(struct command *cmd, struct peer *prev) if (prev != NULL) continue; - /* FIXME: If openingd dies, we'll get stuck here! */ subd_req(p, p->uncommitted_channel->openingd, take(towire_opening_dev_memleak(NULL)), -1, 0, opening_memleak_req_done, cmd); + /* Just in case it dies before replying! */ + tal_add_destructor2(p->uncommitted_channel->openingd, + opening_died_forget_memleak, cmd); return; } opening_memleak_done(cmd, NULL); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index c3499df3e..c8f123e08 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1397,6 +1397,12 @@ static const struct json_command dev_forget_channel_command = { }; AUTODATA(json_command, &dev_forget_channel_command); +static void subd_died_forget_memleak(struct subd *openingd, struct command *cmd) +{ + /* FIXME: We ignore the remaining per-peer daemons in this case. */ + peer_memleak_done(cmd, NULL); +} + /* Mutual recursion */ static void peer_memleak_req_next(struct command *cmd, struct channel *prev); static void peer_memleak_req_done(struct subd *subd, bool found_leak, @@ -1416,6 +1422,7 @@ static void channeld_memleak_req_done(struct subd *channeld, { bool found_leak; + tal_del_destructor2(channeld, subd_died_forget_memleak, cmd); if (!fromwire_channel_dev_memleak_reply(msg, &found_leak)) { command_fail(cmd, LIGHTNINGD, "Bad channel_dev_memleak"); return; @@ -1429,6 +1436,7 @@ static void onchaind_memleak_req_done(struct subd *onchaind, { bool found_leak; + tal_del_destructor2(onchaind, subd_died_forget_memleak, cmd); if (!fromwire_onchain_dev_memleak_reply(msg, &found_leak)) { command_fail(cmd, LIGHTNINGD, "Bad onchain_dev_memleak"); return; @@ -1460,12 +1468,18 @@ static void peer_memleak_req_next(struct command *cmd, struct channel *prev) subd_req(c, c->owner, take(towire_channel_dev_memleak(NULL)), -1, 0, channeld_memleak_req_done, cmd); + tal_add_destructor2(c->owner, + subd_died_forget_memleak, + cmd); return; } if (streq(c->owner->name, "lightning_onchaind")) { subd_req(c, c->owner, take(towire_onchain_dev_memleak(NULL)), -1, 0, onchaind_memleak_req_done, cmd); + tal_add_destructor2(c->owner, + subd_died_forget_memleak, + cmd); return; } }