#include "select.h"
#ifdef USE_WINSOCK
+# undef EBADF
+# define EBADF WSAEBADF
# undef EINTR
# define EINTR WSAEINTR
# undef EINVAL
#define elapsed_ms (int)curlx_tvdiff(curlx_tvnow(), initial_tv)
#ifdef CURL_ACKNOWLEDGE_EINTR
-#define sockerrno_not_EINTR (SOCKERRNO != EINTR)
+#define error_not_EINTR (error != EINTR)
#else
-#define sockerrno_not_EINTR (1)
+#define error_not_EINTR (1)
#endif
/*
#endif
struct timeval initial_tv;
int pending_ms;
+ int error;
#endif
int r = 0;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
r = select(0, NULL, NULL, NULL, &pending_tv);
#endif /* HAVE_POLL_FINE */
- } while ((r == -1) && (SOCKERRNO != EINVAL) && sockerrno_not_EINTR &&
+ } while ((r == -1) && (error = SOCKERRNO) &&
+ (error != EINVAL) && error_not_EINTR &&
((pending_ms = timeout_ms - elapsed_ms) > 0));
#endif /* USE_WINSOCK */
if (r)
#endif
struct timeval initial_tv;
int pending_ms;
+ int error;
int r;
int ret;
if (timeout_ms < 0)
pending_ms = -1;
r = poll(pfd, num, pending_ms);
- } while ((r == -1) && (SOCKERRNO != EINVAL) && sockerrno_not_EINTR &&
+ } while ((r == -1) && (error = SOCKERRNO) &&
+ (error != EINVAL) && error_not_EINTR &&
((timeout_ms < 0) || ((pending_ms = timeout_ms - elapsed_ms) > 0)));
if (r < 0)
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
- } while ((r == -1) && (SOCKERRNO != EINVAL) && sockerrno_not_EINTR &&
+ } while ((r == -1) && (error = SOCKERRNO) &&
+ (error != EINVAL) && (error != EBADF) && error_not_EINTR &&
((timeout_ms < 0) || ((pending_ms = timeout_ms - elapsed_ms) > 0)));
if (r < 0)
bool fds_none = TRUE;
unsigned int i;
int pending_ms;
+ int error;
int r;
if (ufds) {
if (timeout_ms < 0)
pending_ms = -1;
r = poll(ufds, nfds, pending_ms);
- } while ((r == -1) && (SOCKERRNO != EINVAL) && sockerrno_not_EINTR &&
+ } while ((r == -1) && (error = SOCKERRNO) &&
+ (error != EINVAL) && error_not_EINTR &&
((timeout_ms < 0) || ((pending_ms = timeout_ms - elapsed_ms) > 0)));
#else /* HAVE_POLL_FINE */
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
- } while ((r == -1) && (SOCKERRNO != EINVAL) && sockerrno_not_EINTR &&
+ } while ((r == -1) && (error = SOCKERRNO) &&
+ (error != EINVAL) && (error != EBADF) && error_not_EINTR &&
((timeout_ms < 0) || ((pending_ms = timeout_ms - elapsed_ms) > 0)));
if (r < 0)