mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
plugin: Cleanup a plugin as soon as its stdout closes
We were waiting for both stdin and stdout to close, however that resulted in us deferring cleanup indefinitely since we did not poll stdout for being writable most of the time. On the other hand we are almost always polling the plugin's stdout, so that notifies us as soon as the plugin stops. Changelog-Fixed: plugin: Plugins no longer linger indefinitely if their process terminates
This commit is contained in:
committed by
Rusty Russell
parent
72757933f0
commit
644daa02e3
@@ -439,13 +439,7 @@ static struct io_plan *plugin_write_json(struct io_conn *conn,
|
||||
*/
|
||||
static void plugin_conn_finish(struct io_conn *conn, struct plugin *plugin)
|
||||
{
|
||||
if (conn == plugin->stdin_conn)
|
||||
plugin->stdin_conn = NULL;
|
||||
|
||||
else if (conn == plugin->stdout_conn)
|
||||
plugin->stdout_conn = NULL;
|
||||
|
||||
if (plugin->stdin_conn == NULL && plugin->stdout_conn == NULL)
|
||||
tal_free(plugin);
|
||||
}
|
||||
|
||||
@@ -454,8 +448,8 @@ struct io_plan *plugin_stdin_conn_init(struct io_conn *conn,
|
||||
{
|
||||
/* We write to their stdin */
|
||||
/* We don't have anything queued yet, wait for notification */
|
||||
plugin->stdin_conn = tal_steal(plugin, conn);
|
||||
plugin->stdin_conn = conn;
|
||||
io_set_finish(conn, plugin_conn_finish, plugin);
|
||||
return io_wait(plugin->stdin_conn, plugin, plugin_write_json, plugin);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user