mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
plugins: remove dynamic plugins configuration code from lightningd/plugin
This merges back plugins_init and plugins_start, removes conditions on startup, and removes the CONFIGURING state.
This commit is contained in:
@@ -50,6 +50,7 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
|||||||
p->log_book = log_book;
|
p->log_book = log_book;
|
||||||
p->log = new_log(p, log_book, "plugin-manager");
|
p->log = new_log(p, log_book, "plugin-manager");
|
||||||
p->ld = ld;
|
p->ld = ld;
|
||||||
|
p->startup = true;
|
||||||
uintmap_init(&p->pending_requests);
|
uintmap_init(&p->pending_requests);
|
||||||
memleak_add_helper(p, memleak_help_pending_requests);
|
memleak_add_helper(p, memleak_help_pending_requests);
|
||||||
|
|
||||||
@@ -849,19 +850,14 @@ static void plugin_manifest_cb(const char *buffer,
|
|||||||
struct plugin *plugin)
|
struct plugin *plugin)
|
||||||
{
|
{
|
||||||
/* Check if all plugins have replied to getmanifest, and break
|
/* Check if all plugins have replied to getmanifest, and break
|
||||||
* if they have and this is the startup init */
|
* if they have */
|
||||||
plugin->plugins->pending_manifests--;
|
plugin->plugins->pending_manifests--;
|
||||||
if (plugin->plugins->startup && plugin->plugins->pending_manifests == 0)
|
if (plugin->plugins->pending_manifests == 0)
|
||||||
io_break(plugin->plugins);
|
io_break(plugin->plugins);
|
||||||
|
|
||||||
if (!plugin_parse_getmanifest_response(buffer, toks, idtok, plugin))
|
if (!plugin_parse_getmanifest_response(buffer, toks, idtok, plugin))
|
||||||
plugin_kill(plugin, "%s: Bad response to getmanifest.", plugin->cmd);
|
plugin_kill(plugin, "%s: Bad response to getmanifest.", plugin->cmd);
|
||||||
|
|
||||||
/* If all plugins have replied to getmanifest and this is not
|
|
||||||
* the startup init, configure them */
|
|
||||||
if (!plugin->plugins->startup && plugin->plugins->pending_manifests == 0)
|
|
||||||
plugins_config(plugin->plugins);
|
|
||||||
|
|
||||||
/* Reset timer, it'd kill us otherwise. */
|
/* Reset timer, it'd kill us otherwise. */
|
||||||
tal_free(plugin->timeout_timer);
|
tal_free(plugin->timeout_timer);
|
||||||
}
|
}
|
||||||
@@ -976,17 +972,21 @@ void plugins_add_default_dir(struct plugins *plugins, const char *default_dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugins_start(struct plugins *plugins, const char *dev_plugin_debug)
|
void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
||||||
{
|
{
|
||||||
struct plugin *p;
|
struct plugin *p;
|
||||||
char **cmd;
|
char **cmd;
|
||||||
int stdin, stdout;
|
int stdin, stdout;
|
||||||
struct jsonrpc_request *req;
|
struct jsonrpc_request *req;
|
||||||
|
|
||||||
list_for_each(&plugins->plugins, p, list) {
|
plugins->pending_manifests = 0;
|
||||||
if (p->plugin_state != UNCONFIGURED)
|
plugins_add_default_dir(plugins,
|
||||||
continue;
|
path_join(tmpctx, plugins->ld->config_dir, "plugins"));
|
||||||
|
|
||||||
|
setenv("LIGHTNINGD_PLUGIN", "1", 1);
|
||||||
|
setenv("LIGHTNINGD_VERSION", version(), 1);
|
||||||
|
/* Spawn the plugin processes before entering the io_loop */
|
||||||
|
list_for_each(&plugins->plugins, p, list) {
|
||||||
bool debug;
|
bool debug;
|
||||||
|
|
||||||
debug = dev_plugin_debug && strends(p->cmd, dev_plugin_debug);
|
debug = dev_plugin_debug && strends(p->cmd, dev_plugin_debug);
|
||||||
@@ -1025,18 +1025,6 @@ void plugins_start(struct plugins *plugins, const char *dev_plugin_debug)
|
|||||||
}
|
}
|
||||||
tal_free(cmd);
|
tal_free(cmd);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
|
|
||||||
{
|
|
||||||
plugins->pending_manifests = 0;
|
|
||||||
plugins_add_default_dir(plugins,
|
|
||||||
path_join(tmpctx, plugins->ld->config_dir, "plugins"));
|
|
||||||
|
|
||||||
setenv("LIGHTNINGD_PLUGIN", "1", 1);
|
|
||||||
setenv("LIGHTNINGD_VERSION", version(), 1);
|
|
||||||
/* Spawn the plugin processes before entering the io_loop */
|
|
||||||
plugins_start(plugins, dev_plugin_debug);
|
|
||||||
|
|
||||||
if (plugins->pending_manifests > 0)
|
if (plugins->pending_manifests > 0)
|
||||||
io_loop_with_timers(plugins->ld);
|
io_loop_with_timers(plugins->ld);
|
||||||
@@ -1095,10 +1083,8 @@ void plugins_config(struct plugins *plugins)
|
|||||||
{
|
{
|
||||||
struct plugin *p;
|
struct plugin *p;
|
||||||
list_for_each(&plugins->plugins, p, list) {
|
list_for_each(&plugins->plugins, p, list) {
|
||||||
if (p->plugin_state == UNCONFIGURED) {
|
if (p->plugin_state == UNCONFIGURED)
|
||||||
p->plugin_state = CONFIGURING;
|
|
||||||
plugin_config(p);
|
plugin_config(p);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins->startup = false;
|
plugins->startup = false;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
enum plugin_state {
|
enum plugin_state {
|
||||||
UNCONFIGURED,
|
UNCONFIGURED,
|
||||||
CONFIGURING,
|
|
||||||
CONFIGURED
|
CONFIGURED
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +30,6 @@ struct plugin {
|
|||||||
|
|
||||||
/* If this plugin can be restarted without restarting lightningd */
|
/* If this plugin can be restarted without restarting lightningd */
|
||||||
bool dynamic;
|
bool dynamic;
|
||||||
bool signal_startup;
|
|
||||||
|
|
||||||
/* Stuff we read */
|
/* Stuff we read */
|
||||||
char *buffer;
|
char *buffer;
|
||||||
@@ -109,8 +107,6 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
|
|||||||
*/
|
*/
|
||||||
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir);
|
void plugins_add_default_dir(struct plugins *plugins, const char *default_dir);
|
||||||
|
|
||||||
void plugins_start(struct plugins *plugins, const char *dev_plugin_debug);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the registered plugins.
|
* Initialize the registered plugins.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user