mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightningd: make plugin_kill take a simple string.
That's more convenient for most callers, which don't need a fmt. Fixed-by: Darosior <darosior@protonmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -186,15 +186,8 @@ bool plugin_remove(struct plugins *plugins, const char *name)
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_kill(struct plugin *plugin, char *fmt, ...)
|
void plugin_kill(struct plugin *plugin, const char *msg)
|
||||||
{
|
{
|
||||||
char *msg;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
msg = tal_vfmt(plugin, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
log_info(plugin->log, "Killing plugin: %s", msg);
|
log_info(plugin->log, "Killing plugin: %s", msg);
|
||||||
plugin->stop = true;
|
plugin->stop = true;
|
||||||
io_wake(plugin);
|
io_wake(plugin);
|
||||||
@@ -474,7 +467,7 @@ static struct io_plan *plugin_read_json(struct io_conn *conn,
|
|||||||
return io_close(NULL);
|
return io_close(NULL);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plugin_kill(plugin, "%s", err);
|
plugin_kill(plugin, err);
|
||||||
/* plugin_kill frees plugin */
|
/* plugin_kill frees plugin */
|
||||||
return io_close(NULL);
|
return io_close(NULL);
|
||||||
}
|
}
|
||||||
@@ -968,10 +961,13 @@ static const char *plugin_hooks_add(struct plugin *plugin, const char *buffer,
|
|||||||
static void plugin_manifest_timeout(struct plugin *plugin)
|
static void plugin_manifest_timeout(struct plugin *plugin)
|
||||||
{
|
{
|
||||||
bool startup = plugin->plugins->startup;
|
bool startup = plugin->plugins->startup;
|
||||||
|
if (plugin->plugin_state == AWAITING_GETMANIFEST_RESPONSE)
|
||||||
plugin_kill(plugin,
|
plugin_kill(plugin,
|
||||||
"failed to respond to \"%s\" in time, terminating.",
|
"failed to respond to 'getmanifest' in time, terminating.");
|
||||||
plugin->plugin_state == AWAITING_GETMANIFEST_RESPONSE
|
else
|
||||||
? "getmanifest" : "init");
|
plugin_kill(plugin,
|
||||||
|
"failed to respond to 'init' in time, terminating.");
|
||||||
|
|
||||||
if (startup)
|
if (startup)
|
||||||
fatal("Can't recover from plugin failure, terminating.");
|
fatal("Can't recover from plugin failure, terminating.");
|
||||||
}
|
}
|
||||||
@@ -1093,7 +1089,7 @@ static void plugin_manifest_cb(const char *buffer,
|
|||||||
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin);
|
err = plugin_parse_getmanifest_response(buffer, toks, idtok, plugin);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
plugin_kill(plugin, "%s", err);
|
plugin_kill(plugin, err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1288,9 +1284,8 @@ bool plugins_send_getmanifest(struct plugins *plugins)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plugins->startup)
|
if (plugins->startup)
|
||||||
fatal("error starting plugin '%s': %s", p->cmd,
|
fatal("error starting plugin '%s': %s", p->cmd, err);
|
||||||
strerror(errno));
|
plugin_kill(p, err);
|
||||||
plugin_kill(p, "error starting: %s", strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sent;
|
return sent;
|
||||||
|
|||||||
@@ -209,9 +209,9 @@ const char *plugin_send_getmanifest(struct plugin *p);
|
|||||||
bool plugins_send_getmanifest(struct plugins *plugins);
|
bool plugins_send_getmanifest(struct plugins *plugins);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kill a plugin process, with an error message.
|
* Kill a plugin process and free @plugin, with an error message.
|
||||||
*/
|
*/
|
||||||
void plugin_kill(struct plugin *plugin, char *fmt, ...) PRINTF_FMT(2,3);
|
void plugin_kill(struct plugin *plugin, const char *msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the plugin which registers the command with name {cmd_name}
|
* Returns the plugin which registers the command with name {cmd_name}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ def test_plugin_slowinit(node_factory):
|
|||||||
os.environ['SLOWINIT_TIME'] = '61'
|
os.environ['SLOWINIT_TIME'] = '61'
|
||||||
n = node_factory.get_node()
|
n = node_factory.get_node()
|
||||||
|
|
||||||
with pytest.raises(RpcError, match='failed to respond to "init" in time, terminating.'):
|
with pytest.raises(RpcError, match='failed to respond to \'init\' in time, terminating.'):
|
||||||
n.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/slow_init.py"))
|
n.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/slow_init.py"))
|
||||||
|
|
||||||
# It's not actually configured yet, see what happens;
|
# It's not actually configured yet, see what happens;
|
||||||
|
|||||||
Reference in New Issue
Block a user