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
This commit is contained in:
Wim Taymans 2024-02-06 11:10:27 +01:00
parent 97777f173a
commit 0bc42d71e0

View file

@ -213,10 +213,15 @@ static const struct command command_list[] = {
{ "quit", "q", "Quit", do_quit }, { "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) static bool do_quit(struct data *data, const char *cmd, char *args, char **error)
{ {
pw_main_loop_quit(data->loop); program_quit(data);
data->quit = true;
return true; 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); id, seq, res, spa_strerror(res), message);
if (id == PW_ID_CORE && res == -EPIPE) 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 = { 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) static void do_quit_on_signal(void *data, int signal_number)
{ {
struct data *d = data; struct data *d = data;
d->quit = true; program_quit(d);
pw_main_loop_quit(d->loop);
} }
static void show_help(struct data *data, const char *name, bool error) static void show_help(struct data *data, const char *name, bool error)