#ifdef OS_IS_WIN32
+#include "poll.h"
+
/* Returns the directory of the current DLL, with '/bin/' removed if it is the last component */
char *pa_win32_get_toplevel(HANDLE handle) {
static char *toplevel = NULL;
#ifdef OS_IS_WIN32
if (!type || *type == 0) {
+ int err;
ssize_t r;
+retry:
if ((r = recv(fd, buf, count, 0)) >= 0)
return r;
- if (WSAGetLastError() != WSAENOTSOCK) {
- errno = WSAGetLastError();
+ err = WSAGetLastError();
+ if (err != WSAENOTSOCK) {
+ /* transparently handle non-blocking sockets, by waiting
+ * for readiness */
+ if (err == WSAEWOULDBLOCK) {
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+ if (pa_poll(&pfd, 1, -1) >= 0) {
+ goto retry;
+ }
+ }
+ errno = err;
return r;
}
if (!type || *type == 0) {
ssize_t r;
+ int err;
+retry:
for (;;) {
if ((r = send(fd, buf, count, MSG_NOSIGNAL)) < 0) {
}
#ifdef OS_IS_WIN32
- if (WSAGetLastError() != WSAENOTSOCK) {
- errno = WSAGetLastError();
+ err = WSAGetLastError();
+ if (err != WSAENOTSOCK) {
+ /* transparently handle non-blocking sockets, by waiting
+ * for readiness */
+ if (err == WSAEWOULDBLOCK) {
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
+ if (pa_poll(&pfd, 1, -1) >= 0) {
+ goto retry;
+ }
+ }
+ errno = err;
return r;
}
#else