mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
lightningd: don't process request twice if plugin dies.
We remove it from the pending_requests strmap before calling it, so it doesn't get called again by destroy_plugin. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7c1d07a94f
commit
6f1bb6fa41
2 changed files with 9 additions and 7 deletions
|
@ -629,6 +629,12 @@ static bool was_plugin_destroyed(struct plugin_destroyed *pd)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void destroy_request(struct jsonrpc_request *req,
|
||||
struct plugin *plugin)
|
||||
{
|
||||
strmap_del(&plugin->pending_requests, req->id, NULL);
|
||||
}
|
||||
|
||||
static void plugin_response_handle(struct plugin *plugin,
|
||||
const jsmntok_t *toks,
|
||||
const jsmntok_t *idtok)
|
||||
|
@ -648,6 +654,9 @@ static void plugin_response_handle(struct plugin *plugin,
|
|||
/* Request callback often frees request: if not, we do. */
|
||||
ctx = tal(NULL, char);
|
||||
tal_steal(ctx, request);
|
||||
/* Don't keep track of this request; we will terminate it */
|
||||
tal_del_destructor2(request, destroy_request, plugin);
|
||||
destroy_request(request, plugin);
|
||||
request->response_cb(plugin->buffer, toks, idtok, request->response_cb_arg);
|
||||
tal_free(ctx);
|
||||
}
|
||||
|
@ -2356,12 +2365,6 @@ void plugins_notify(struct plugins *plugins,
|
|||
}
|
||||
}
|
||||
|
||||
static void destroy_request(struct jsonrpc_request *req,
|
||||
struct plugin *plugin)
|
||||
{
|
||||
strmap_del(&plugin->pending_requests, req->id, NULL);
|
||||
}
|
||||
|
||||
void plugin_request_send(struct plugin *plugin,
|
||||
struct jsonrpc_request *req)
|
||||
{
|
||||
|
|
|
@ -1478,7 +1478,6 @@ def test_sendpay_notifications_nowaiter(node_factory):
|
|||
assert len(results['sendpay_failure']) == 1
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_rpc_command_hook(node_factory):
|
||||
"""Test the `rpc_command` hook chain"""
|
||||
plugin = [
|
||||
|
|
Loading…
Add table
Reference in a new issue