lightningd: complete plugin state machine.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-05-05 10:42:29 +09:30
parent 6a9c4e65c3
commit ee401e62a2
3 changed files with 7 additions and 0 deletions

View File

@ -1145,6 +1145,7 @@ void plugins_init(struct plugins *plugins, const char *dev_plugin_debug)
plugin_manifest_cb, p);
jsonrpc_request_end(req);
plugin_request_send(p, req);
p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;
plugins->pending_manifests++;
/* Don't timeout if they're running a debugger. */
@ -1232,6 +1233,7 @@ plugin_config(struct plugin *plugin)
plugin_populate_init_request(plugin, req);
jsonrpc_request_end(req);
plugin_request_send(plugin, req);
plugin->plugin_state = AWAITING_INIT_RESPONSE;
}
void plugins_config(struct plugins *plugins)

View File

@ -24,6 +24,8 @@
enum plugin_state {
/* We have to ask getmanifest */
UNCONFIGURED,
/* We sent getmanifest, need response. */
AWAITING_GETMANIFEST_RESPONSE,
/* Got `getmanifest` reply, now we need to send `init`. */
NEEDS_INIT,
/* We have to get `init` response */

View File

@ -97,6 +97,7 @@ static void plugin_dynamic_config(struct dynamic_plugin *dp)
plugin_dynamic_config_callback, dp);
plugin_populate_init_request(dp->plugin, req);
jsonrpc_request_end(req);
dp->plugin->plugin_state = AWAITING_INIT_RESPONSE;
plugin_request_send(dp->plugin, req);
}
@ -112,6 +113,7 @@ static void plugin_dynamic_manifest_callback(const char *buffer,
return was_pending(plugin_dynamic_error(dp, "Not a dynamic plugin"));
/* We got the manifest, now send the init message */
dp->plugin->plugin_state = NEEDS_INIT;
plugin_dynamic_config(dp);
}
@ -167,6 +169,7 @@ static struct command_result *plugin_start(struct dynamic_plugin *dp)
plugin_dynamic_manifest_callback, dp);
jsonrpc_request_end(req);
plugin_request_send(p, req);
p->plugin_state = AWAITING_GETMANIFEST_RESPONSE;
return command_still_pending(dp->cmd);
}