mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
plugins: Add a destructor to the plugin request, in case it dies
Authored-by: @rustyrussell
This commit is contained in:
parent
61c07bca45
commit
d0ccd15ac0
@ -252,7 +252,6 @@ static void plugin_response_handle(struct plugin *plugin,
|
||||
/* We expect the request->cb to copy if needed */
|
||||
request->response_cb(plugin->buffer, toks, idtok, request->response_cb_arg);
|
||||
|
||||
uintmap_del(&plugin->plugins->pending_requests, id);
|
||||
tal_free(request);
|
||||
}
|
||||
|
||||
@ -1118,12 +1117,20 @@ void plugins_notify(struct plugins *plugins,
|
||||
tal_free(n);
|
||||
}
|
||||
|
||||
static void destroy_request(struct jsonrpc_request *req,
|
||||
struct plugin *plugin)
|
||||
{
|
||||
uintmap_del(&plugin->plugins->pending_requests, req->id);
|
||||
}
|
||||
|
||||
void plugin_request_send(struct plugin *plugin,
|
||||
struct jsonrpc_request *req TAKES)
|
||||
{
|
||||
/* Add to map so we can find it later when routing the response */
|
||||
tal_steal(plugin, req);
|
||||
uintmap_add(&plugin->plugins->pending_requests, req->id, req);
|
||||
/* Add destructor in case plugin dies. */
|
||||
tal_add_destructor2(req, destroy_request, plugin);
|
||||
plugin_send(plugin, req->stream);
|
||||
/* plugin_send steals the stream, so remove the dangling
|
||||
* pointer here */
|
||||
|
Loading…
Reference in New Issue
Block a user