ray/thirdparty/patches/hiredis-windows-poll.patch
mehrdadn fc76586518
Redis on Windows (#7509)
* Switch hiredis on Windows to that of the Windows port of Redis

* Use boost::asio::ip::tcp::socket::native_handle_type

* Use normal hiredis instead of Windows-specific one

* Finish up using normal hiredis

Co-authored-by: Mehrdad <noreply@github.com>
2020-03-09 18:49:54 -07:00

30 lines
823 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(_get_osfhandle(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(_get_osfhandle(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)");
--