pulse-server: if all transport methods failed, fail server creation

No point in keeping a server running if it doesn't listen to anything.
This commit is contained in:
Peter Hutterer 2021-05-26 08:58:08 +10:00 committed by Wim Taymans
parent 3aacc719b2
commit 6d19dd0162

View file

@ -6234,6 +6234,7 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
struct spa_cpu *cpu; struct spa_cpu *cpu;
uint32_t n_support; uint32_t n_support;
int res; int res;
size_t ncreated = 0;
impl = calloc(1, sizeof(struct impl) + user_data_size); impl = calloc(1, sizeof(struct impl) + user_data_size);
if (impl == NULL) if (impl == NULL)
@ -6291,12 +6292,17 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
spa_json_init(&it[0], str, strlen(str)); spa_json_init(&it[0], str, strlen(str));
if (spa_json_enter_array(&it[0], &it[1]) > 0) { if (spa_json_enter_array(&it[0], &it[1]) > 0) {
while (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) { while (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) {
if (create_server(impl, value) == NULL) { if (create_server(impl, value)) {
ncreated++;
} else {
pw_log_warn(NAME" %p: can't create server for %s: %m", pw_log_warn(NAME" %p: can't create server for %s: %m",
impl, value); impl, value);
} }
} }
} }
if (ncreated == 0)
goto error_free;
if ((res = create_pid_file()) < 0) { if ((res = create_pid_file()) < 0) {
pw_log_warn(NAME" %p: can't create pid file: %s", pw_log_warn(NAME" %p: can't create pid file: %s",
impl, spa_strerror(res)); impl, spa_strerror(res));