mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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:
@@ -969,6 +969,7 @@ bool plugin_parse_getmanifest_response(const char *buffer,
|
||||
!plugin_hooks_add(plugin, buffer, resulttok))
|
||||
return false;
|
||||
|
||||
plugin->plugin_state = NEEDS_INIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1167,7 +1168,7 @@ static void plugin_config_cb(const char *buffer,
|
||||
const jsmntok_t *idtok,
|
||||
struct plugin *plugin)
|
||||
{
|
||||
plugin->plugin_state = CONFIGURED;
|
||||
plugin->plugin_state = INIT_COMPLETE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1240,7 +1241,7 @@ void plugins_config(struct plugins *plugins)
|
||||
{
|
||||
struct plugin *p;
|
||||
list_for_each(&plugins->plugins, p, list) {
|
||||
if (p->plugin_state == UNCONFIGURED)
|
||||
if (p->plugin_state == NEEDS_INIT)
|
||||
plugin_config(p);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user