mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
plugin: Remove special case for plugin stopping while handling hooks
This used to be necessary because we allocated the `plugin_hook_request` off of the plugin instance (only tal allocated object we could grab at that time. Now the plugin was replaced by a list, which itself is tal-allocated, making that workaround pointless, or even wrong once we have multiple plugins registering for that hook.
This commit is contained in:
parent
a3ab3d2990
commit
d639bdd416
@ -102,7 +102,6 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks,
|
|||||||
{
|
{
|
||||||
const jsmntok_t *resulttok, *resrestok;
|
const jsmntok_t *resulttok, *resrestok;
|
||||||
struct db *db = r->db;
|
struct db *db = r->db;
|
||||||
struct plugin_destroyed *pd;
|
|
||||||
bool more_plugins = r->current_plugin + 1 < tal_count(r->hook->plugins);
|
bool more_plugins = r->current_plugin + 1 < tal_count(r->hook->plugins);
|
||||||
|
|
||||||
resulttok = json_get_member(buffer, toks, "result");
|
resulttok = json_get_member(buffer, toks, "result");
|
||||||
@ -115,18 +114,16 @@ static void plugin_hook_callback(const char *buffer, const jsmntok_t *toks,
|
|||||||
resrestok = json_get_member(buffer, resulttok, "result");
|
resrestok = json_get_member(buffer, resulttok, "result");
|
||||||
|
|
||||||
/* If this is a hook response containing a `continue` and we have more
|
/* If this is a hook response containing a `continue` and we have more
|
||||||
* plugins queue the next call. */
|
* plugins queue the next call. In that case we discard the remainder
|
||||||
|
* of the result, and let the next plugin decide. */
|
||||||
if (resrestok && json_tok_streq(buffer, resrestok, "continue") &&
|
if (resrestok && json_tok_streq(buffer, resrestok, "continue") &&
|
||||||
more_plugins) {
|
more_plugins) {
|
||||||
plugin_hook_call_next(r);
|
plugin_hook_call_next(r);
|
||||||
} else {
|
} else {
|
||||||
/* If command is "plugin stop", this can free r! */
|
|
||||||
pd = plugin_detect_destruction(r->plugin);
|
|
||||||
db_begin_transaction(db);
|
db_begin_transaction(db);
|
||||||
r->hook->response_cb(r->cb_arg, buffer, resulttok);
|
r->hook->response_cb(r->cb_arg, buffer, resulttok);
|
||||||
db_commit_transaction(db);
|
db_commit_transaction(db);
|
||||||
if (!was_plugin_destroyed(pd))
|
tal_free(r);
|
||||||
tal_free(r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user