lightningd: avoid false memleak positive with rpc_command_hook.

On `dev-memleak`, if someone is using rpc_command_hook, we'll call
it when the hook returns.  But it will see these contexts as a leak.

So attach them to tmpctx (which is excluded from leak detection).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-11-07 11:57:37 +10:30
parent 5681c088cf
commit bfc00bc7f2

View File

@ -615,7 +615,7 @@ static void mark_plugin_destroyed(const struct plugin *unused,
static struct plugin_destroyed * static struct plugin_destroyed *
plugin_detect_destruction(const struct plugin *plugin) plugin_detect_destruction(const struct plugin *plugin)
{ {
struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed); struct plugin_destroyed *pd = notleak(tal(NULL, struct plugin_destroyed));
pd->plugin = plugin; pd->plugin = plugin;
tal_add_destructor2(plugin, mark_plugin_destroyed, pd); tal_add_destructor2(plugin, mark_plugin_destroyed, pd);
return pd; return pd;
@ -655,7 +655,7 @@ static void plugin_response_handle(struct plugin *plugin,
/* Request callback often frees request: if not, we do. */ /* Request callback often frees request: if not, we do. */
ctx = tal(NULL, char); ctx = tal(tmpctx, char);
tal_steal(ctx, request); tal_steal(ctx, request);
/* Don't keep track of this request; we will terminate it */ /* Don't keep track of this request; we will terminate it */
tal_del_destructor2(request, destroy_request, plugin); tal_del_destructor2(request, destroy_request, plugin);