mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugin: Remove added JSON-RPC methods if a plugin gets killed
Removes the method from the dispatch table, leaving a NULL entry currently. Signed-off-by: Christian Decker <@cdecker>
This commit is contained in:
committed by
Rusty Russell
parent
7de4c40b77
commit
a71208b2a0
@@ -118,6 +118,8 @@ static void plugin_kill(struct plugin *plugin, char *msg)
|
||||
plugin->stop = true;
|
||||
io_wake(plugin);
|
||||
kill(plugin->pid, SIGKILL);
|
||||
list_del(&plugin->list);
|
||||
tal_free(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,8 +386,10 @@ static bool plugin_opts_add(const struct plugin_request *req)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void plugin_rpcmethod_destroy(struct json_command *cmd)
|
||||
static void plugin_rpcmethod_destroy(struct json_command *cmd,
|
||||
struct jsonrpc *rpc)
|
||||
{
|
||||
jsonrpc_command_remove(rpc, cmd->name);
|
||||
}
|
||||
|
||||
static void plugin_rpcmethod_dispatch(struct command *cmd, const char *buffer,
|
||||
@@ -448,7 +452,7 @@ static bool plugin_rpcmethod_add(struct plugin *plugin, const char *buffer,
|
||||
|
||||
cmd->deprecated = false;
|
||||
cmd->dispatch = plugin_rpcmethod_dispatch;
|
||||
tal_add_destructor(cmd, plugin_rpcmethod_destroy);
|
||||
tal_add_destructor2(cmd, plugin_rpcmethod_destroy, plugin->plugins->rpc);
|
||||
if (!jsonrpc_command_add(plugin->plugins->rpc, cmd)) {
|
||||
log_broken(plugin->log,
|
||||
"Could not register method \"%s\", a method with "
|
||||
|
||||
Reference in New Issue
Block a user