diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-09-12 00:17:51 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-09-12 00:17:51 +0000 |
commit | d9c4c9509d34ba89db06ff1252f3da18c6fd623b (patch) | |
tree | c43528c07e55bd4aaa2cf618056e7679c9c7f14a /src/pulsecore | |
parent | 7f92542420ef6085b6f090954052266cc70af8a1 (diff) |
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
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/core-util.c | 13 | ||||
-rw-r--r-- | src/pulsecore/core-util.h | 2 | ||||
-rw-r--r-- | src/pulsecore/fdsem.c | 3 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 62a63761..5becdef0 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1323,3 +1323,16 @@ void *pa_will_need(const void *p, size_t l) { 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; +} + diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index fcafe63d..efd19f45 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -120,4 +120,6 @@ static inline unsigned pa_make_power_of_two(unsigned n) { return n + 1; } +void pa_close_pipe(int fds[2]); + #endif diff --git a/src/pulsecore/fdsem.c b/src/pulsecore/fdsem.c index 710a74f5..68207a76 100644 --- a/src/pulsecore/fdsem.c +++ b/src/pulsecore/fdsem.c @@ -67,8 +67,7 @@ pa_fdsem *pa_fdsem_new(void) { void pa_fdsem_free(pa_fdsem *f) { pa_assert(f); - pa_assert_se(pa_close(f->fds[0]) == 0); - pa_assert_se(pa_close(f->fds[1]) == 0); + pa_close_pipe(f->fds); pa_xfree(f); } |