mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
add new pa_pipe_close() API to close two fds at the same time
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1812 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
7f92542420
commit
d9c4c9509d
8 changed files with 21 additions and 27 deletions
|
|
@ -222,11 +222,7 @@ void pa_cpu_limit_done(void) {
|
||||||
api = NULL;
|
api = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (the_pipe[0] >= 0)
|
pa_close_pipe(the_pipe);
|
||||||
pa_assert_se(pa_close(the_pipe[0]) == 0);
|
|
||||||
if (the_pipe[1] >= 0)
|
|
||||||
pa_assert_se(pa_close(the_pipe[1]) == 0);
|
|
||||||
the_pipe[0] = the_pipe[1] = -1;
|
|
||||||
|
|
||||||
if (installed) {
|
if (installed) {
|
||||||
pa_assert_se(sigaction(SIGXCPU, &sigaction_prev, NULL) >= 0);
|
pa_assert_se(sigaction(SIGXCPU, &sigaction_prev, NULL) >= 0);
|
||||||
|
|
|
||||||
|
|
@ -158,14 +158,6 @@ static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_pipe(int p[2]) {
|
|
||||||
if (p[0] != -1)
|
|
||||||
pa_assert_se(pa_close(p[0]) == 0);
|
|
||||||
if (p[1] != -1)
|
|
||||||
pa_assert_se(pa_close(p[1]) == 0);
|
|
||||||
p[0] = p[1] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define set_env(key, value) putenv(pa_sprintf_malloc("%s=%s", (key), (value)))
|
#define set_env(key, value) putenv(pa_sprintf_malloc("%s=%s", (key), (value)))
|
||||||
|
|
||||||
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
|
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
|
||||||
|
|
@ -745,7 +737,7 @@ finish:
|
||||||
if (valid_pid_file)
|
if (valid_pid_file)
|
||||||
pa_pid_file_remove();
|
pa_pid_file_remove();
|
||||||
|
|
||||||
close_pipe(daemon_pipe);
|
pa_close_pipe(daemon_pipe);
|
||||||
|
|
||||||
#ifdef OS_IS_WIN32
|
#ifdef OS_IS_WIN32
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
|
|
||||||
|
|
@ -585,10 +585,7 @@ static int context_connect_spawn(pa_context *c) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (fds[0] != -1)
|
pa_close_pipe(fds);
|
||||||
pa_assert_se(pa_close(fds[0]) == 0);
|
|
||||||
if (fds[1] != -1)
|
|
||||||
pa_assert_se(pa_close(fds[1]) == 0);
|
|
||||||
|
|
||||||
unlock_autospawn_lock_file(c);
|
unlock_autospawn_lock_file(c);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,7 @@ void pa_signal_done(void) {
|
||||||
api->io_free(io_event);
|
api->io_free(io_event);
|
||||||
io_event = NULL;
|
io_event = NULL;
|
||||||
|
|
||||||
pa_assert_se(close(signal_pipe[0]) == 0);
|
pa_close_pipe(signal_pipe);
|
||||||
pa_assert_se(close(signal_pipe[1]) == 0);
|
|
||||||
signal_pipe[0] = signal_pipe[1] = -1;
|
|
||||||
|
|
||||||
api = NULL;
|
api = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -605,10 +605,7 @@ void pa_mainloop_free(pa_mainloop* m) {
|
||||||
|
|
||||||
pa_xfree(m->pollfds);
|
pa_xfree(m->pollfds);
|
||||||
|
|
||||||
if (m->wakeup_pipe[0] >= 0)
|
pa_close_pipe(m->wakeup_pipe);
|
||||||
pa_assert_se(pa_close(m->wakeup_pipe[0]) == 0);
|
|
||||||
if (m->wakeup_pipe[1] >= 0)
|
|
||||||
pa_assert_se(pa_close(m->wakeup_pipe[1]) == 0);
|
|
||||||
|
|
||||||
pa_xfree(m);
|
pa_xfree(m);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1323,3 +1323,16 @@ void *pa_will_need(const void *p, size_t l) {
|
||||||
|
|
||||||
return (void*) p;
|
return (void*) p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pa_close_pipe(int fds[2]) {
|
||||||
|
pa_assert(fds);
|
||||||
|
|
||||||
|
if (fds[0] >= 0)
|
||||||
|
pa_assert_se(pa_close(fds[0]) == 0);
|
||||||
|
|
||||||
|
if (fds[1] >= 0)
|
||||||
|
pa_assert_se(pa_close(fds[1]) == 0);
|
||||||
|
|
||||||
|
fds[0] = fds[1] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,4 +120,6 @@ static inline unsigned pa_make_power_of_two(unsigned n) {
|
||||||
return n + 1;
|
return n + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pa_close_pipe(int fds[2]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,7 @@ pa_fdsem *pa_fdsem_new(void) {
|
||||||
void pa_fdsem_free(pa_fdsem *f) {
|
void pa_fdsem_free(pa_fdsem *f) {
|
||||||
pa_assert(f);
|
pa_assert(f);
|
||||||
|
|
||||||
pa_assert_se(pa_close(f->fds[0]) == 0);
|
pa_close_pipe(f->fds);
|
||||||
pa_assert_se(pa_close(f->fds[1]) == 0);
|
|
||||||
|
|
||||||
pa_xfree(f);
|
pa_xfree(f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue