mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
memdump: rearrange order to avoid command_its_complicated().
memdump iterates through the various daemons asking them to check for leaks. We currently call openingds (there might be none), channelds (there might be none), then hsmd synchronously (the other daemons). If hsmd reports a leak, we'll fail the dev-memleak command immediately. Change the order to call connectd first; that's always async, so we can happily mark the command still pending. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e5c61fcb0c
commit
26484b8aa5
1 changed files with 12 additions and 15 deletions
|
@ -218,7 +218,6 @@ static void connect_dev_memleak_done(struct subd *connectd,
|
|||
const int *fds UNUSED,
|
||||
struct command *cmd)
|
||||
{
|
||||
struct lightningd *ld = cmd->ld;
|
||||
bool found_leak;
|
||||
|
||||
if (!fromwire_connect_dev_memleak_reply(reply, &found_leak)) {
|
||||
|
@ -232,9 +231,8 @@ static void connect_dev_memleak_done(struct subd *connectd,
|
|||
return;
|
||||
}
|
||||
|
||||
/* No leak? Ask gossipd. */
|
||||
subd_req(ld->gossip, ld->gossip, take(towire_gossip_dev_memleak(NULL)),
|
||||
-1, 0, gossip_dev_memleak_done, cmd);
|
||||
/* No leak? Ask openingd. */
|
||||
opening_dev_memleak(cmd);
|
||||
}
|
||||
|
||||
static void hsm_dev_memleak_done(struct subd *hsmd,
|
||||
|
@ -255,10 +253,9 @@ static void hsm_dev_memleak_done(struct subd *hsmd,
|
|||
return;
|
||||
}
|
||||
|
||||
/* No leak? Ask connectd. */
|
||||
subd_req(ld->connectd, ld->connectd,
|
||||
take(towire_connect_dev_memleak(NULL)),
|
||||
-1, 0, connect_dev_memleak_done, cmd);
|
||||
/* No leak? Ask gossipd. */
|
||||
subd_req(ld->gossip, ld->gossip, take(towire_gossip_dev_memleak(NULL)),
|
||||
-1, 0, gossip_dev_memleak_done, cmd);
|
||||
}
|
||||
|
||||
void peer_memleak_done(struct command *cmd, struct subd *leaker)
|
||||
|
@ -292,6 +289,8 @@ static struct command_result *json_memleak(struct command *cmd,
|
|||
const jsmntok_t *obj UNNEEDED,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
struct lightningd *ld = cmd->ld;
|
||||
|
||||
if (!param(cmd, buffer, params, NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -300,14 +299,12 @@ static struct command_result *json_memleak(struct command *cmd,
|
|||
"Leak detection needs $LIGHTNINGD_DEV_MEMLEAK");
|
||||
}
|
||||
|
||||
/* For simplicity, we mark pending, though an error may complete it
|
||||
* immediately. */
|
||||
fixme_ignore(command_still_pending(cmd));
|
||||
/* Start by asking connectd, which is always async. */
|
||||
subd_req(ld->connectd, ld->connectd,
|
||||
take(towire_connect_dev_memleak(NULL)),
|
||||
-1, 0, connect_dev_memleak_done, cmd);
|
||||
|
||||
/* This calls opening_memleak_done() async when all done. */
|
||||
opening_dev_memleak(cmd);
|
||||
|
||||
return command_its_complicated();
|
||||
return command_still_pending(cmd);
|
||||
}
|
||||
|
||||
static const struct json_command dev_memleak_command = {
|
||||
|
|
Loading…
Add table
Reference in a new issue