mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 16:44:20 +01:00
lightningd: fix race where we do rescan before all plugins finish init.
The symptom (under heavy load and valgrind) in test_plugin_command: lightningd: common/json_stream.c:237: json_stream_output_: Assertion `!js->reader' failed. This is because we try to call `getmanifest` again on `pay` which has not yet responded to init. The minimal fix for this is to keep proper state, so we can tell the difference between "not yet called getmanifest" and "not yet finished init". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -25,7 +25,7 @@ static struct command_result *plugin_dynamic_list_plugins(struct command *cmd)
|
||||
json_object_start(response, NULL);
|
||||
json_add_string(response, "name", p->cmd);
|
||||
json_add_bool(response, "active",
|
||||
p->plugin_state == CONFIGURED);
|
||||
p->plugin_state == INIT_COMPLETE);
|
||||
json_object_end(response);
|
||||
}
|
||||
json_array_end(response);
|
||||
@@ -69,14 +69,14 @@ static void plugin_dynamic_config_callback(const char *buffer,
|
||||
{
|
||||
struct plugin *p;
|
||||
|
||||
dp->plugin->plugin_state = CONFIGURED;
|
||||
dp->plugin->plugin_state = INIT_COMPLETE;
|
||||
/* Reset the timer only now so that we are either configured, or
|
||||
* killed. */
|
||||
tal_free(dp->plugin->timeout_timer);
|
||||
tal_del_destructor2(dp->plugin, plugin_dynamic_crash, dp);
|
||||
|
||||
list_for_each(&dp->plugin->plugins->plugins, p, list) {
|
||||
if (p->plugin_state != CONFIGURED)
|
||||
if (p->plugin_state != INIT_COMPLETE)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user