From 426ff0abfff8b080b22095b9f0b670c7192f54ea Mon Sep 17 00:00:00 2001 From: Simon Vrouwe Date: Mon, 13 Dec 2021 10:49:24 +0200 Subject: [PATCH] lightningd: cleanup obsolete plugins->shutdown flag After leaving the main event loop, the only path to destroy_plugin goes via shutdown_plugins. --- lightningd/lightningd.c | 1 - lightningd/plugin.c | 9 +++------ lightningd/plugin.h | 3 --- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 54b47317d..f406e68d0 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -243,7 +243,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx) */ ld->plugins = plugins_new(ld, ld->log_book, ld); ld->plugins->startup = true; - ld->plugins->shutdown = false; /*~ This is set when a JSON RPC command comes in to shut us down. */ ld->stop_conn = NULL; diff --git a/lightningd/plugin.c b/lightningd/plugin.c index d1e785468..e0dff8188 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -83,7 +83,6 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book, p->startup = true; p->plugin_cmds = tal_arr(p, struct plugin_command *, 0); p->blacklist = tal_arr(p, const char *, 0); - p->shutdown = false; p->plugin_idx = 0; #if DEVELOPER p->dev_builtin_plugins_unimportant = false; @@ -213,7 +212,7 @@ static void destroy_plugin(struct plugin *p) check_plugins_manifests(p->plugins); /* Daemon shutdown overrules plugin's importance; aborts init checks */ - if (p->plugins->shutdown) { + if (p->plugins->ld->state == LD_STATE_SHUTDOWN) { /* But return if this was the last plugin! */ if (list_empty(&p->plugins->plugins)) io_break(destroy_plugin); @@ -786,7 +785,7 @@ static void plugin_conn_finish(struct io_conn *conn, struct plugin *plugin) { /* This is expected at shutdown of course. */ plugin_kill(plugin, - plugin->plugins->shutdown + plugin->plugins->ld->state == LD_STATE_SHUTDOWN ? LOG_DBG : LOG_INFORM, "exited %s", state_desc(plugin)); } @@ -2092,8 +2091,7 @@ void shutdown_plugins(struct lightningd *ld) { struct plugin *p, *next; - /* Don't complain about important plugins vanishing; close the db. */ - ld->plugins->shutdown = true; + /* The next io_loop does not need db access, close it. */ ld->wallet->db = tal_free(ld->wallet->db); /* Tell them all to shutdown; if they care. */ @@ -2116,7 +2114,6 @@ void shutdown_plugins(struct lightningd *ld) void *ret = io_loop(timer, &expired); assert(ret == NULL || ret == destroy_plugin); - /* Report and free remaining plugins. */ while (!list_empty(&ld->plugins->plugins)) { p = list_pop(&ld->plugins->plugins, struct plugin, list); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index d26509472..14b13ff54 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -113,9 +113,6 @@ struct plugins { /* Blacklist of plugins from --disable-plugin */ const char **blacklist; - /* Whether we are shutting down, blocks db write's */ - bool shutdown; - /* Index to show what order they were added in */ u64 plugin_idx;