mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
lightningd: make plugin opts free themselves.
They are children of the plugin, so this Just Works. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
051cbf7cc4
commit
86615f5405
1 changed files with 8 additions and 9 deletions
|
@ -190,7 +190,6 @@ void plugin_kill(struct plugin *plugin, char *fmt, ...)
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
struct plugin_opt *opt;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
msg = tal_vfmt(plugin, fmt, ap);
|
msg = tal_vfmt(plugin, fmt, ap);
|
||||||
|
@ -202,14 +201,6 @@ void plugin_kill(struct plugin *plugin, char *fmt, ...)
|
||||||
kill(plugin->pid, SIGKILL);
|
kill(plugin->pid, SIGKILL);
|
||||||
list_del(&plugin->list);
|
list_del(&plugin->list);
|
||||||
|
|
||||||
/* FIXME: This cleans up as it goes because plugin_kill called twice! */
|
|
||||||
while ((opt = list_top(&plugin->plugin_opts, struct plugin_opt, list))) {
|
|
||||||
if (!opt_unregister(opt->name))
|
|
||||||
fatal("Could not unregister %s from plugin %s",
|
|
||||||
opt->name, plugin->cmd);
|
|
||||||
list_del_from(&plugin->plugin_opts, &opt->list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin->start_cmd) {
|
if (plugin->start_cmd) {
|
||||||
plugin_cmd_killed(plugin->start_cmd, plugin, msg);
|
plugin_cmd_killed(plugin->start_cmd, plugin, msg);
|
||||||
plugin->start_cmd = NULL;
|
plugin->start_cmd = NULL;
|
||||||
|
@ -606,6 +597,13 @@ char *plugin_opt_set(const char *arg, struct plugin_opt *popt)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroy_plugin_opt(struct plugin_opt *opt)
|
||||||
|
{
|
||||||
|
if (!opt_unregister(opt->name))
|
||||||
|
fatal("Could not unregister %s", opt->name);
|
||||||
|
list_del(&opt->list);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a single plugin option to the plugin as well as registering it with the
|
/* Add a single plugin option to the plugin as well as registering it with the
|
||||||
* command line options. */
|
* command line options. */
|
||||||
static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
||||||
|
@ -679,6 +677,7 @@ static const char *plugin_opt_add(struct plugin *plugin, const char *buffer,
|
||||||
opt_register_arg(popt->name, plugin_opt_set, NULL, popt,
|
opt_register_arg(popt->name, plugin_opt_set, NULL, popt,
|
||||||
popt->description);
|
popt->description);
|
||||||
|
|
||||||
|
tal_add_destructor(popt, destroy_plugin_opt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue