mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-07 23:24:21 +01:00
plugin: plugin_exclusive_loop helper to service one plugin synchronously.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1053,3 +1053,21 @@ void plugin_request_send(struct plugin *plugin,
|
||||
* pointer here */
|
||||
req->stream = NULL;
|
||||
}
|
||||
|
||||
void *plugin_exclusive_loop(struct plugin *plugin)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
io_conn_out_exclusive(plugin->stdin_conn, true);
|
||||
io_conn_exclusive(plugin->stdout_conn, true);
|
||||
|
||||
/* We don't service timers here, either! */
|
||||
ret = io_loop(NULL, NULL);
|
||||
|
||||
io_conn_out_exclusive(plugin->stdin_conn, false);
|
||||
if (io_conn_exclusive(plugin->stdout_conn, false))
|
||||
fatal("Still io_exclusive after removing plugin %s?",
|
||||
plugin->cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,14 @@ void json_add_opt_plugins(struct json_stream *response,
|
||||
const struct plugins *plugins);
|
||||
|
||||
|
||||
/**
|
||||
* Used by db hooks which can't have any other I/O while talking to plugin.
|
||||
*
|
||||
* Returns output of io_loop() (ie. whatever gets passed to io_break()
|
||||
* to end exclusive loop).
|
||||
*/
|
||||
void *plugin_exclusive_loop(struct plugin *plugin);
|
||||
|
||||
/**
|
||||
* Add a directory to the plugin path to automatically load plugins.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user