--- src/pulse/context.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pulse/context.c b/src/pulse/context.c index e03d88c..4d28350 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -657,12 +657,14 @@ static int context_autospawn(pa_context *c) { if (sigaction(SIGCHLD, NULL, &sa) < 0) { pa_log_debug("sigaction() failed: %s", pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); + r = -PA_ERR_INTERNAL; goto fail; } if ((sa.sa_flags & SA_NOCLDWAIT) || sa.sa_handler == SIG_IGN) { pa_log_debug("Process disabled waitpid(), cannot autospawn."); pa_context_fail(c, PA_ERR_CONNECTIONREFUSED); + r = -PA_ERR_CONNECTIONREFUSED; goto fail; } @@ -674,6 +676,7 @@ static int context_autospawn(pa_context *c) { if ((pid = fork()) < 0) { pa_log_error(_("fork(): %s"), pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); + r = -PA_ERR_INTERNAL; if (c->spawn_api.postfork) c->spawn_api.postfork(); @@ -729,6 +732,7 @@ static int context_autospawn(pa_context *c) { if (errno != ESRCH) { pa_log(_("waitpid(): %s"), pa_cstrerror(errno)); pa_context_fail(c, PA_ERR_INTERNAL); + r = -PA_ERR_INTERNAL; goto fail; } @@ -737,6 +741,7 @@ static int context_autospawn(pa_context *c) { } else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { pa_context_fail(c, PA_ERR_CONNECTIONREFUSED); + r = -PA_ERR_CONNECTIONREFUSED; goto fail; } @@ -748,7 +753,7 @@ fail: pa_context_unref(c); - return -1; + return r; } #endif /* OS_IS_WIN32 */ @@ -797,7 +802,7 @@ fail: static int try_next_connection(pa_context *c) { char *u = NULL; - int r = -1; + int r = 0; pa_assert(c); pa_assert(!c->client); @@ -833,10 +838,17 @@ static int try_next_connection(pa_context *c) { track_pulseaudio_on_dbus(c, DBUS_BUS_SESSION, &c->session_bus); if (!c->system_bus) track_pulseaudio_on_dbus(c, DBUS_BUS_SYSTEM, &c->system_bus); + /* XXX: If the track_pulseaudio_on_dbus() calls fail, then the + * context will wait in the PA_CONTEXT_CONNECTING state + * forever. OTOH, that's anyway the case if it happens that no + * daemon ever appears on either bus, so maybe it's not so + * serious? */ } else #endif pa_context_fail(c, PA_ERR_CONNECTIONREFUSED); + r = -PA_ERR_CONNECTIONREFUSED; + goto finish; } @@ -853,8 +865,6 @@ static int try_next_connection(pa_context *c) { break; } - r = 0; - finish: pa_xfree(u); @@ -958,6 +968,7 @@ int pa_context_connect( if (server) { if (!(c->server_list = pa_strlist_parse(server))) { pa_context_fail(c, PA_ERR_INVALIDSERVER); + r = -PA_ERR_INVALIDSERVER; goto finish; } -- 1.7.7.3