X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/4d62f159a74c6e5b46be5823483a7dedd5691b45..dd9265ac78b56c378bc7ca47920be9d9d93392b7:/src/pulsecore/fdsem.c diff --git a/src/pulsecore/fdsem.c b/src/pulsecore/fdsem.c index ea14e8a7..14fcbd6b 100644 --- a/src/pulsecore/fdsem.c +++ b/src/pulsecore/fdsem.c @@ -32,9 +32,9 @@ #include #include -#include #include #include +#include #include #ifndef HAVE_PIPE @@ -153,16 +153,26 @@ static void flush(pa_fdsem *f) { if (f->efd >= 0) { uint64_t u; - if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) { + + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; } r = (ssize_t) u; } else #endif - if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) { + + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; } @@ -186,15 +196,23 @@ void pa_fdsem_post(pa_fdsem *f) { if (f->efd >= 0) { uint64_t u = 1; - if ((r = write(f->efd, &u, sizeof(u))) != sizeof(u)) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_write(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) { + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid write to eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; } } else #endif - if ((r = write(f->fds[1], &x, 1)) != 1) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_write(f->fds[1], &x, 1, NULL)) != 1) { + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid write to pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; } @@ -222,8 +240,13 @@ void pa_fdsem_wait(pa_fdsem *f) { if (f->efd >= 0) { uint64_t u; - if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) { + + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; } @@ -231,8 +254,13 @@ void pa_fdsem_wait(pa_fdsem *f) { } else #endif - if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) { - pa_assert(r < 0 && errno == EINTR); + if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) { + + if (r >= 0 || errno != EINTR) { + pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF"); + pa_assert_not_reached(); + } + continue; }