diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-04-18 23:21:05 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-04-18 23:21:11 +0200 |
commit | ad447d14682a57defb7a06069dec0c1fd91108de (patch) | |
tree | b98738e5b909db0b45fc0574fe85f88e8f21b2d6 /src | |
parent | 099b3284ec7e78da25baa70d42a2ecdc1092b935 (diff) |
core-util: handle EINTR already inside of pa_read/pa_write
Diffstat (limited to 'src')
-rw-r--r-- | src/pulsecore/core-util.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 24d929d7..294f63cb 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -296,7 +296,15 @@ ssize_t pa_read(int fd, void *buf, size_t count, int *type) { #endif - return read(fd, buf, count); + for (;;) { + ssize_t r; + + if ((r = read(fd, buf, count)) < 0) + if (errno == EINTR) + continue; + + return r; + } } /** Similar to pa_read(), but handles writes */ @@ -305,8 +313,17 @@ ssize_t pa_write(int fd, const void *buf, size_t count, int *type) { if (!type || *type == 0) { ssize_t r; - if ((r = send(fd, buf, count, MSG_NOSIGNAL)) >= 0) + for (;;) { + if ((r = send(fd, buf, count, MSG_NOSIGNAL)) < 0) { + + if (errno == EINTR) + continue; + + break; + } + return r; + } #ifdef OS_IS_WIN32 if (WSAGetLastError() != WSAENOTSOCK) { @@ -322,7 +339,15 @@ ssize_t pa_write(int fd, const void *buf, size_t count, int *type) { *type = 1; } - return write(fd, buf, count); + for (;;) { + ssize_t r; + + if ((r = write(fd, buf, count)) < 0) + if (errno == EINTR) + continue; + + return r; + } } /** Calls read() in a loop. Makes sure that as much as 'size' bytes, @@ -407,11 +432,11 @@ int pa_close(int fd) { for (;;) { int r; - if ((r = close(fd)) >= 0) - return r; + if ((r = close(fd)) < 0) + if (errno == EINTR) + continue; - if (errno != EINTR) - return r; + return r; } } |