mirror of
https://github.com/vale981/ray
synced 2025-03-06 18:41:40 -05:00
51 lines
1.4 KiB
Diff
51 lines
1.4 KiB
Diff
diff --git deps/hiredis/net.c deps/hiredis/net.c
|
|
--- deps/hiredis/net.c
|
|
+++ deps/hiredis/net.c
|
|
@@ -60,6 +60,10 @@
|
|
static void redisContextCloseFd(redisContext *c) {
|
|
if (c && c->fd >= 0) {
|
|
+#ifdef _WINSOCKAPI_
|
|
+ closesocket(c->fd);
|
|
+#else
|
|
close(c->fd);
|
|
+#endif
|
|
c->fd = -1;
|
|
}
|
|
}
|
|
@@ -102,24 +106,33 @@
|
|
static int redisSetBlocking(redisContext *c, int blocking) {
|
|
int flags;
|
|
|
|
- /* Set the socket nonblocking.
|
|
+ /* Set the socket nonblocking. */
|
|
+#ifdef _WINSOCKAPI_
|
|
+ unsigned long value = !blocking;
|
|
+ if (ioctlsocket(c->fd, FIONBIO, &value) == SOCKET_ERROR) {
|
|
+ __redisSetErrorFromErrno(c,REDIS_ERR_IO,"ioctlsocket(FIONBIO)");
|
|
+ redisContextCloseFd(c);
|
|
+ return REDIS_ERR;
|
|
+ }
|
|
+#else
|
|
- * Note that fcntl(2) for F_GETFL and F_SETFL can't be
|
|
+ /* Note that fcntl(2) for F_GETFL and F_SETFL can't be
|
|
* interrupted by a signal. */
|
|
if ((flags = fcntl(c->fd, F_GETFL)) == -1) {
|
|
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"fcntl(F_GETFL)");
|
|
redisContextCloseFd(c);
|
|
return REDIS_ERR;
|
|
}
|
|
|
|
if (blocking)
|
|
flags &= ~O_NONBLOCK;
|
|
else
|
|
flags |= O_NONBLOCK;
|
|
|
|
if (fcntl(c->fd, F_SETFL, flags) == -1) {
|
|
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"fcntl(F_SETFL)");
|
|
redisContextCloseFd(c);
|
|
return REDIS_ERR;
|
|
}
|
|
+#endif
|
|
return REDIS_OK;
|
|
}
|
|
--
|