mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
plugin: Avoid calling a destructor on a request that was freed
We are attaching the destructor to notify us when the plugin exits, but we also need to clear them once the request is handled correctly, so we don't call the destructor when it exits later.
This commit is contained in:
committed by
Rusty Russell
parent
41a5728fc3
commit
0987747ded
@@ -155,7 +155,7 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks,
|
||||
const jsmntok_t *resulttok, *resrestok;
|
||||
struct db *db = r->db;
|
||||
bool more_plugins, cont;
|
||||
struct plugin_hook_call_link *last;
|
||||
struct plugin_hook_call_link *last, *it;
|
||||
|
||||
if (r->ld->state == LD_STATE_SHUTDOWN) {
|
||||
log_debug(r->ld->log,
|
||||
@@ -200,6 +200,15 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks,
|
||||
db_begin_transaction(db);
|
||||
r->hook->response_cb(r->cb_arg, buffer, resulttok);
|
||||
db_commit_transaction(db);
|
||||
|
||||
/* We need to remove the destructors from the remaining
|
||||
* call-chain, otherwise they'd still be called when the
|
||||
* plugin dies or we shut down. */
|
||||
list_for_each(&r->call_chain, it, list) {
|
||||
tal_del_destructor(it, plugin_hook_killed);
|
||||
tal_steal(r, it);
|
||||
}
|
||||
|
||||
tal_free(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user