mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
lightningd: unify dynamic and static plugin initialization.
This means we now clean up options in startup plugins (that was only done by dynamic code!), and now they both share the 60 second timeout instead of 20 seconds for dynamic. For the dynamic case though, it's 60 seconds to both complete getmanifest and init, which seems fair. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -190,6 +190,7 @@ void plugin_kill(struct plugin *plugin, char *fmt, ...)
|
||||
{
|
||||
char *msg;
|
||||
va_list ap;
|
||||
struct plugin_opt *opt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
msg = tal_vfmt(plugin, fmt, ap);
|
||||
@@ -201,8 +202,18 @@ void plugin_kill(struct plugin *plugin, char *fmt, ...)
|
||||
kill(plugin->pid, SIGKILL);
|
||||
list_del(&plugin->list);
|
||||
|
||||
if (plugin->start_cmd)
|
||||
/* 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) {
|
||||
plugin_cmd_killed(plugin->start_cmd, plugin, msg);
|
||||
plugin->start_cmd = NULL;
|
||||
}
|
||||
|
||||
check_plugins_resolved(plugin->plugins);
|
||||
}
|
||||
@@ -494,13 +505,15 @@ static struct io_plan *plugin_write_json(struct io_conn *conn,
|
||||
*/
|
||||
static void plugin_conn_finish(struct io_conn *conn, struct plugin *plugin)
|
||||
{
|
||||
struct plugins *plugins = plugin->plugins;
|
||||
plugin->stdout_conn = NULL;
|
||||
if (plugin->start_cmd) {
|
||||
plugin_cmd_succeeded(plugin->start_cmd, plugin);
|
||||
plugin_cmd_killed(plugin->start_cmd, plugin,
|
||||
"Plugin exited before completing handshake.");
|
||||
plugin->start_cmd = NULL;
|
||||
}
|
||||
tal_free(plugin);
|
||||
check_plugins_resolved(plugin->plugins);
|
||||
check_plugins_resolved(plugins);
|
||||
}
|
||||
|
||||
struct io_plan *plugin_stdin_conn_init(struct io_conn *conn,
|
||||
|
||||
Reference in New Issue
Block a user