mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-03 22:34:21 +01:00
openingd: wire up dev_memleak.
This is a bit different from the other cases: we need to iterate through the peers and ask all the ones in openingd. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -675,6 +675,9 @@ static unsigned int openingd_msg(struct subd *openingd,
|
||||
case WIRE_OPENING_INIT:
|
||||
case WIRE_OPENING_FUNDER:
|
||||
case WIRE_OPENING_CAN_ACCEPT_CHANNEL:
|
||||
case WIRE_OPENING_DEV_MEMLEAK:
|
||||
/* Replies never get here */
|
||||
case WIRE_OPENING_DEV_MEMLEAK_REPLY:
|
||||
break;
|
||||
}
|
||||
log_broken(openingd->log, "Unexpected msg %s: %s",
|
||||
@@ -855,3 +858,58 @@ static const struct json_command fund_channel_command = {
|
||||
"Fund channel with {id} using {satoshi} (or 'all') satoshis, at optional {feerate}"
|
||||
};
|
||||
AUTODATA(json_command, &fund_channel_command);
|
||||
|
||||
#if DEVELOPER
|
||||
/* Indented to avoid include ordering check */
|
||||
#include <lightningd/memdump.h>
|
||||
|
||||
/* Mutual recursion */
|
||||
static void opening_memleak_req_next(struct command *cmd, struct peer *prev);
|
||||
static void opening_memleak_req_done(struct subd *openingd,
|
||||
const u8 *msg, const int *fds UNUSED,
|
||||
struct command *cmd)
|
||||
{
|
||||
bool found_leak;
|
||||
struct uncommitted_channel *uc = openingd->channel;
|
||||
|
||||
if (!fromwire_opening_dev_memleak_reply(msg, &found_leak)) {
|
||||
command_fail(cmd, LIGHTNINGD, "Bad opening_dev_memleak");
|
||||
return;
|
||||
}
|
||||
|
||||
if (found_leak) {
|
||||
opening_memleak_done(cmd, openingd);
|
||||
return;
|
||||
}
|
||||
opening_memleak_req_next(cmd, uc->peer);
|
||||
}
|
||||
|
||||
static void opening_memleak_req_next(struct command *cmd, struct peer *prev)
|
||||
{
|
||||
struct peer *p;
|
||||
|
||||
list_for_each(&cmd->ld->peers, p, list) {
|
||||
if (!p->uncommitted_channel)
|
||||
continue;
|
||||
if (p == prev) {
|
||||
prev = NULL;
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
opening_memleak_done(cmd, NULL);
|
||||
}
|
||||
|
||||
void opening_dev_memleak(struct command *cmd)
|
||||
{
|
||||
opening_memleak_req_next(cmd, NULL);
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
Reference in New Issue
Block a user