mirror of
https://github.com/wassname/ray.git
synced 2026-07-26 13:37:24 +08:00
Patch hiredis for Windows (#6446)
This commit is contained in:
@@ -72,12 +72,18 @@ def github_repository(*, name=None, remote=None, commit=None, tag=None,
|
||||
def ray_deps_setup():
|
||||
github_repository(
|
||||
name = "redis",
|
||||
build_file = "@//bazel:BUILD.redis",
|
||||
build_file = True,
|
||||
tag = "5.0.3",
|
||||
remote = "https://github.com/antirez/redis",
|
||||
sha256 = "8e5997b447b1afdd1efd33731968484d2fe71c271fa7f1cd6b2476367e964e0e",
|
||||
patches = [
|
||||
"//thirdparty/patches:hiredis-async-include-dict.patch",
|
||||
"//thirdparty/patches:hiredis-casts.patch",
|
||||
"//thirdparty/patches:hiredis-connect-rename.patch",
|
||||
"//thirdparty/patches:hiredis-windows-sigpipe.patch",
|
||||
"//thirdparty/patches:hiredis-windows-sockets.patch",
|
||||
"//thirdparty/patches:hiredis-windows-strerror.patch",
|
||||
"//thirdparty/patches:hiredis-windows-poll.patch",
|
||||
"//thirdparty/patches:redis-windows-poll.patch",
|
||||
],
|
||||
)
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
diff --git deps/hiredis/net.c deps/hiredis/net.c
|
||||
--- deps/hiredis/net.c
|
||||
+++ deps/hiredis/net.c
|
||||
@@ -79,1 +79,1 @@
|
||||
- if (setsockopt(c->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
|
||||
+ if (setsockopt(c->fd, SOL_SOCKET, SO_REUSEADDR, (char const *)&on, sizeof(on)) == -1) {
|
||||
@@ -131,1 +131,1 @@
|
||||
- if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) == -1){
|
||||
+ if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char const *)&val, sizeof(val)) == -1){
|
||||
@@ -139,1 +139,1 @@
|
||||
- if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) {
|
||||
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, (char const *)&val, sizeof(val)) < 0) {
|
||||
@@ -146,1 +146,1 @@
|
||||
- if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
|
||||
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (char const *)&val, sizeof(val)) < 0) {
|
||||
@@ -153,1 +153,1 @@
|
||||
- if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
|
||||
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (char const *)&val, sizeof(val)) < 0) {
|
||||
@@ -159,1 +159,1 @@
|
||||
- if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &val, sizeof(val)) < 0) {
|
||||
+ if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, (char const *)&val, sizeof(val)) < 0) {
|
||||
@@ -171,1 +171,1 @@
|
||||
- if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) == -1) {
|
||||
+ if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, (char const *)&yes, sizeof(yes)) == -1) {
|
||||
@@ -240,1 +240,1 @@
|
||||
- if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == -1) {
|
||||
+ if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen) == -1) {
|
||||
@@ -255,5 +255,5 @@
|
||||
- if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv)) == -1) {
|
||||
+ if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,(char const *)&tv,sizeof(tv)) == -1) {
|
||||
@@ -259,1 +259,1 @@
|
||||
- if (setsockopt(c->fd,SOL_SOCKET,SO_SNDTIMEO,&tv,sizeof(tv)) == -1) {
|
||||
+ if (setsockopt(c->fd,SOL_SOCKET,SO_SNDTIMEO,(char const *)&tv,sizeof(tv)) == -1) {
|
||||
--
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
diff --git deps/hiredis/test.c deps/hiredis/test.c
|
||||
--- deps/hiredis/test.c
|
||||
+++ deps/hiredis/test.c
|
||||
@@ -94,1 +94,1 @@
|
||||
-static redisContext *connect(struct config config) {
|
||||
+static redisContext *connect_(struct config config) {
|
||||
@@ -251,1 +251,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -390,1 +390,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -471,1 +471,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -483,1 +483,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -517,1 +517,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -552,1 +552,1 @@
|
||||
- c = connect(config);
|
||||
+ c = connect_(config);
|
||||
@@ -586,1 +586,1 @@
|
||||
- redisContext *c = connect(config);
|
||||
+ redisContext *c = connect_(config);
|
||||
--
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
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)");
|
||||
--
|
||||
@@ -0,0 +1,9 @@
|
||||
diff --git deps/hiredis/test.c deps/hiredis/test.c
|
||||
--- deps/hiredis/test.c
|
||||
+++ deps/hiredis/test.c
|
||||
@@ -762,2 +762,4 @@ int main(int argc, char **argv) {
|
||||
+#ifndef _WIN32
|
||||
/* Ignore broken pipe signal (for I/O error tests). */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
+#endif
|
||||
--
|
||||
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
}
|
||||
--
|
||||
@@ -0,0 +1,17 @@
|
||||
diff --git deps/hiredis/hiredis.h deps/hiredis/hiredis.h
|
||||
--- deps/hiredis/hiredis.h
|
||||
+++ deps/hiredis/hiredis.h
|
||||
@@ -87,5 +87,12 @@
|
||||
+#ifdef _WIN32
|
||||
+#define __redis_strerror_r(errno, buf, len) \
|
||||
+ do { \
|
||||
+ strerror_s((buf), (len), (errno)); \
|
||||
+ } while (0)
|
||||
+#else
|
||||
/* "regular" POSIX strerror_r that does the right thing. */
|
||||
#define __redis_strerror_r(errno, buf, len) \
|
||||
do { \
|
||||
strerror_r((errno), (buf), (len)); \
|
||||
} while (0)
|
||||
+#endif
|
||||
--
|
||||
Reference in New Issue
Block a user