Skip to content

Commit

Permalink
lightningd: cleanup obsolete plugins->shutdown flag
Browse files Browse the repository at this point in the history
After leaving the main event loop, the only path to destroy_plugin
goes via shutdown_plugins.
  • Loading branch information
SimonVrouwe committed Dec 13, 2021
1 parent 7d29c70 commit 8132509
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
1 change: 0 additions & 1 deletion lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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. */
Expand All @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions lightningd/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 8132509

Please sign in to comment.