mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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:
committed by
Rusty Russell
parent
28816c387c
commit
426ff0abff
@@ -243,7 +243,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||||||
*/
|
*/
|
||||||
ld->plugins = plugins_new(ld, ld->log_book, ld);
|
ld->plugins = plugins_new(ld, ld->log_book, ld);
|
||||||
ld->plugins->startup = true;
|
ld->plugins->startup = true;
|
||||||
ld->plugins->shutdown = false;
|
|
||||||
|
|
||||||
/*~ This is set when a JSON RPC command comes in to shut us down. */
|
/*~ This is set when a JSON RPC command comes in to shut us down. */
|
||||||
ld->stop_conn = NULL;
|
ld->stop_conn = NULL;
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
|||||||
p->startup = true;
|
p->startup = true;
|
||||||
p->plugin_cmds = tal_arr(p, struct plugin_command *, 0);
|
p->plugin_cmds = tal_arr(p, struct plugin_command *, 0);
|
||||||
p->blacklist = tal_arr(p, const char *, 0);
|
p->blacklist = tal_arr(p, const char *, 0);
|
||||||
p->shutdown = false;
|
|
||||||
p->plugin_idx = 0;
|
p->plugin_idx = 0;
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
p->dev_builtin_plugins_unimportant = false;
|
p->dev_builtin_plugins_unimportant = false;
|
||||||
@@ -213,7 +212,7 @@ static void destroy_plugin(struct plugin *p)
|
|||||||
check_plugins_manifests(p->plugins);
|
check_plugins_manifests(p->plugins);
|
||||||
|
|
||||||
/* Daemon shutdown overrules plugin's importance; aborts init checks */
|
/* 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! */
|
/* But return if this was the last plugin! */
|
||||||
if (list_empty(&p->plugins->plugins))
|
if (list_empty(&p->plugins->plugins))
|
||||||
io_break(destroy_plugin);
|
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. */
|
/* This is expected at shutdown of course. */
|
||||||
plugin_kill(plugin,
|
plugin_kill(plugin,
|
||||||
plugin->plugins->shutdown
|
plugin->plugins->ld->state == LD_STATE_SHUTDOWN
|
||||||
? LOG_DBG : LOG_INFORM,
|
? LOG_DBG : LOG_INFORM,
|
||||||
"exited %s", state_desc(plugin));
|
"exited %s", state_desc(plugin));
|
||||||
}
|
}
|
||||||
@@ -2092,8 +2091,7 @@ void shutdown_plugins(struct lightningd *ld)
|
|||||||
{
|
{
|
||||||
struct plugin *p, *next;
|
struct plugin *p, *next;
|
||||||
|
|
||||||
/* Don't complain about important plugins vanishing; close the db. */
|
/* The next io_loop does not need db access, close it. */
|
||||||
ld->plugins->shutdown = true;
|
|
||||||
ld->wallet->db = tal_free(ld->wallet->db);
|
ld->wallet->db = tal_free(ld->wallet->db);
|
||||||
|
|
||||||
/* Tell them all to shutdown; if they care. */
|
/* Tell them all to shutdown; if they care. */
|
||||||
@@ -2116,7 +2114,6 @@ void shutdown_plugins(struct lightningd *ld)
|
|||||||
void *ret = io_loop(timer, &expired);
|
void *ret = io_loop(timer, &expired);
|
||||||
assert(ret == NULL || ret == destroy_plugin);
|
assert(ret == NULL || ret == destroy_plugin);
|
||||||
|
|
||||||
|
|
||||||
/* Report and free remaining plugins. */
|
/* Report and free remaining plugins. */
|
||||||
while (!list_empty(&ld->plugins->plugins)) {
|
while (!list_empty(&ld->plugins->plugins)) {
|
||||||
p = list_pop(&ld->plugins->plugins, struct plugin, list);
|
p = list_pop(&ld->plugins->plugins, struct plugin, list);
|
||||||
|
|||||||
@@ -113,9 +113,6 @@ struct plugins {
|
|||||||
/* Blacklist of plugins from --disable-plugin */
|
/* Blacklist of plugins from --disable-plugin */
|
||||||
const char **blacklist;
|
const char **blacklist;
|
||||||
|
|
||||||
/* Whether we are shutting down, blocks db write's */
|
|
||||||
bool shutdown;
|
|
||||||
|
|
||||||
/* Index to show what order they were added in */
|
/* Index to show what order they were added in */
|
||||||
u64 plugin_idx;
|
u64 plugin_idx;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user