libplugin: mark the cmd notleak() whenever command_still_pending() called.

This is what we do in lightningd, which makes memleak much more forgiving:
you can hang temporaries off cmd without getting reports of leaks (also
when send_outreq called).

We remove all the notleak() calls in plugins which worked around this!
And avoid multiple notleak labels, since both send_outreq() and
command_still_pending() can be called multiple times.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-09-16 12:45:03 +09:30
parent 701dd3dcef
commit 5b58eda748
8 changed files with 19 additions and 37 deletions

View File

@@ -297,6 +297,8 @@ struct command_result *command_finished(struct command *cmd,
struct command_result *WARN_UNUSED_RESULT
command_still_pending(struct command *cmd)
{
if (cmd)
notleak_with_children(cmd);
return &pending;
}
@@ -728,6 +730,8 @@ send_outreq(struct plugin *plugin, const struct out_req *req)
ld_rpc_send(plugin, req->js);
if (req->cmd != NULL)
notleak_with_children(req->cmd);
return &pending;
}