From 0bc42d71e04210cbbf19f400e4a72194669f5b64 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 6 Feb 2024 11:10:27 +0100 Subject: [PATCH] pw-cli: set quit flag on -EPIPE When the server closes the connection in non-interactive mode, we need to set the quit flag to avoid going into second mainloop_run() that will just block forever. See #3837 --- src/tools/pw-cli.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index edb502f72..2b1d6c8ac 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -213,10 +213,15 @@ static const struct command command_list[] = { { "quit", "q", "Quit", do_quit }, }; +static void program_quit(struct data *data) +{ + data->quit = true; + pw_main_loop_quit(data->loop); +} + static bool do_quit(struct data *data, const char *cmd, char *args, char **error) { - pw_main_loop_quit(data->loop); - data->quit = true; + program_quit(data); return true; } @@ -446,7 +451,7 @@ static void on_core_error(void *_data, uint32_t id, int seq, int res, const char id, seq, res, spa_strerror(res), message); if (id == PW_ID_CORE && res == -EPIPE) - pw_main_loop_quit(data->loop); + program_quit(data); } static const struct pw_core_events remote_core_events = { @@ -2239,8 +2244,7 @@ static void readline_cleanup(void) static void do_quit_on_signal(void *data, int signal_number) { struct data *d = data; - d->quit = true; - pw_main_loop_quit(d->loop); + program_quit(d); } static void show_help(struct data *data, const char *name, bool error)