Browse Source

plugin: plugin_exclusive_loop helper to service one plugin synchronously.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pr-2587
Rusty Russell 6 years ago
parent
commit
3729ad9914
  1. 18
      lightningd/plugin.c
  2. 8
      lightningd/plugin.h

18
lightningd/plugin.c

@ -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;
}

8
lightningd/plugin.h

@ -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.
*/

Loading…
Cancel
Save