mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-19 04:54:25 +01:00
onchaind: wire up dev_memleak.
For onchaind we need to remove globals from memleak consideration; we also change the htlc pointer to an htlc copy, which simplifies things as well. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -327,6 +327,8 @@ static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds U
|
||||
case WIRE_ONCHAIN_DEPTH:
|
||||
case WIRE_ONCHAIN_HTLC:
|
||||
case WIRE_ONCHAIN_KNOWN_PREIMAGE:
|
||||
case WIRE_ONCHAIN_DEV_MEMLEAK:
|
||||
case WIRE_ONCHAIN_DEV_MEMLEAK_REPLY:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1399,23 +1399,41 @@ AUTODATA(json_command, &dev_forget_channel_command);
|
||||
|
||||
/* 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,
|
||||
struct command *cmd)
|
||||
{
|
||||
struct channel *c = subd->channel;
|
||||
|
||||
if (found_leak)
|
||||
peer_memleak_done(cmd, subd);
|
||||
else
|
||||
peer_memleak_req_next(cmd, c);
|
||||
}
|
||||
|
||||
static void channeld_memleak_req_done(struct subd *channeld,
|
||||
const u8 *msg, const int *fds UNUSED,
|
||||
struct command *cmd)
|
||||
{
|
||||
struct channel *c = channeld->channel;
|
||||
bool found_leak;
|
||||
|
||||
if (!fromwire_channel_dev_memleak_reply(msg, &found_leak)) {
|
||||
command_fail(cmd, LIGHTNINGD, "Bad channel_dev_memleak");
|
||||
return;
|
||||
}
|
||||
peer_memleak_req_done(channeld, found_leak, cmd);
|
||||
}
|
||||
|
||||
if (found_leak) {
|
||||
peer_memleak_done(cmd, channeld);
|
||||
static void onchaind_memleak_req_done(struct subd *onchaind,
|
||||
const u8 *msg, const int *fds UNUSED,
|
||||
struct command *cmd)
|
||||
{
|
||||
bool found_leak;
|
||||
|
||||
if (!fromwire_onchain_dev_memleak_reply(msg, &found_leak)) {
|
||||
command_fail(cmd, LIGHTNINGD, "Bad onchain_dev_memleak");
|
||||
return;
|
||||
}
|
||||
peer_memleak_req_next(cmd, c);
|
||||
peer_memleak_req_done(onchaind, found_leak, cmd);
|
||||
}
|
||||
|
||||
static void peer_memleak_req_next(struct command *cmd, struct channel *prev)
|
||||
@@ -1437,7 +1455,6 @@ static void peer_memleak_req_next(struct command *cmd, struct channel *prev)
|
||||
if (prev != NULL)
|
||||
continue;
|
||||
|
||||
/* FIXME: handle onchaind here */
|
||||
/* FIXME: handle closingd here */
|
||||
if (streq(c->owner->name, "lightning_channeld")) {
|
||||
subd_req(c, c->owner,
|
||||
@@ -1445,6 +1462,12 @@ static void peer_memleak_req_next(struct command *cmd, struct channel *prev)
|
||||
-1, 0, channeld_memleak_req_done, 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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
peer_memleak_done(cmd, NULL);
|
||||
|
||||
@@ -85,6 +85,9 @@ bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, secp256k1_ecd
|
||||
/* Generated stub for fromwire_hsm_sign_invoice_reply */
|
||||
bool fromwire_hsm_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_hsm_sign_invoice_reply called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_dev_memleak_reply */
|
||||
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
|
||||
/* Generated stub for get_block_height */
|
||||
u32 get_block_height(const struct chain_topology *topo UNNEEDED)
|
||||
{ fprintf(stderr, "get_block_height called!\n"); abort(); }
|
||||
@@ -386,6 +389,9 @@ u8 *towire_hsm_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct pubkey
|
||||
/* Generated stub for towire_hsm_sign_invoice */
|
||||
u8 *towire_hsm_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)
|
||||
{ fprintf(stderr, "towire_hsm_sign_invoice called!\n"); abort(); }
|
||||
/* Generated stub for towire_onchain_dev_memleak */
|
||||
u8 *towire_onchain_dev_memleak(const tal_t *ctx UNNEEDED)
|
||||
{ fprintf(stderr, "towire_onchain_dev_memleak called!\n"); abort(); }
|
||||
/* Generated stub for txfilter_add_scriptpubkey */
|
||||
void txfilter_add_scriptpubkey(struct txfilter *filter UNNEEDED, const u8 *script TAKES UNNEEDED)
|
||||
{ fprintf(stderr, "txfilter_add_scriptpubkey called!\n"); abort(); }
|
||||
|
||||
Reference in New Issue
Block a user