lightningd: cleanup obsolete plugins->shutdown flag

After leaving the main event loop, the only path to destroy_plugin
goes via shutdown_plugins.
This commit is contained in:
Simon Vrouwe 2021-12-13 10:49:24 +02:00 committed by Rusty Russell
parent 28816c387c
commit 426ff0abff
3 changed files with 3 additions and 10 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;