mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
core-util: handle EINTR already inside of pa_read/pa_write
This commit is contained in:
parent
099b3284ec
commit
ad447d1468
1 changed files with 32 additions and 7 deletions
|
|
@ -296,7 +296,15 @@ ssize_t pa_read(int fd, void *buf, size_t count, int *type) {
|
||||||
|
|
||||||
#endif
|
#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 */
|
/** 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) {
|
if (!type || *type == 0) {
|
||||||
ssize_t r;
|
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;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OS_IS_WIN32
|
#ifdef OS_IS_WIN32
|
||||||
if (WSAGetLastError() != WSAENOTSOCK) {
|
if (WSAGetLastError() != WSAENOTSOCK) {
|
||||||
|
|
@ -322,7 +339,15 @@ ssize_t pa_write(int fd, const void *buf, size_t count, int *type) {
|
||||||
*type = 1;
|
*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,
|
/** Calls read() in a loop. Makes sure that as much as 'size' bytes,
|
||||||
|
|
@ -407,11 +432,11 @@ int pa_close(int fd) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if ((r = close(fd)) >= 0)
|
if ((r = close(fd)) < 0)
|
||||||
return r;
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (errno != EINTR)
|
return r;
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue