ray/thirdparty/patches/hiredis-windows-poll.patch
2019-12-17 15:32:47 -08:00

30 lines
791 B
Diff

diff --git deps/hiredis/net.c deps/hiredis/net.c
--- deps/hiredis/net.c
+++ deps/hiredis/net.c
@@ -204,11 +204,24 @@
static int redisContextWaitReady(redisContext *c, long msec) {
+#ifdef _WINSOCKAPI_
+ fd_set wset;
+
+ FD_ZERO(&wset);
+ FD_SET(c->fd, &wset);
+#else
struct pollfd wfd[1];
wfd[0].fd = c->fd;
wfd[0].events = POLLOUT;
+#endif
if (errno == EINPROGRESS) {
int res;
+#ifdef _WINSOCKAPI_
+ struct timeval tv = { msec / 1000, (msec % 1000) * 1000 };
+ res = select(c->fd + 1, NULL, &wset, NULL, msec >= 0 ? &tv : NULL);
+#else
+ res = poll(wfd, 1, msec);
+#endif
- if ((res = poll(wfd, 1, msec)) == -1) {
+ if (res == -1) {
__redisSetErrorFromErrno(c, REDIS_ERR_IO, "poll(2)");
--