lightningd: handle properly if our own request to plugin is freed.

We should really unify the cases of a local request, vs a forwarded
request, but for now, don't steal the request onto the plugin, and
if we return from the plugin and the request is gone, don't get upset.

This uncovered a case where we weren't inside a transaction, in
test_hook_crash, so fix that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-10-24 12:11:30 +10:30
parent db7f59eeba
commit 7c1d07a94f
2 changed files with 22 additions and 35 deletions

View File

@@ -73,7 +73,7 @@ struct plugin {
/* An array of subscribed topics */
char **subscriptions;
/* Currently pending requests by their request ID */
/* Our pending requests by their request ID */
STRMAP(struct jsonrpc_request *) pending_requests;
/* If set, the plugin is so important that if it terminates early,
@@ -322,9 +322,13 @@ void plugins_notify(struct plugins *plugins,
/**
* Send a jsonrpc_request to the specified plugin
* @plugin: the plugin to send the request to
* @req: the request.
*
* If @req is freed, any response from the plugin is ignored.
*/
void plugin_request_send(struct plugin *plugin,
struct jsonrpc_request *req TAKES);
struct jsonrpc_request *req);
/**
* Callback called when parsing options. It just stores the value in