Update hiredis and remove Windows patches (#9289)

Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
mehrdadn 2020-07-09 18:45:44 -07:00 committed by GitHub
parent dc51b08c36
commit dd2cc6eb48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 9 additions and 136 deletions

View file

@ -25,6 +25,7 @@ cc_library(
],
exclude =
[
"ssl.c",
"test.c",
],
),
@ -32,14 +33,7 @@ cc_library(
"*.h",
"adapters/*.h",
]),
copts = COPTS + select({
"@bazel_tools//src/conditions:windows": [
"-D" + "WIN32_REPLACE_FD_APIS",
"/FI" + "win32fd.h",
],
"//conditions:default": [
],
}),
copts = COPTS,
include_prefix = "hiredis",
deps = [
":_hiredis",

View file

@ -89,14 +89,10 @@ def ray_deps_setup():
auto_http_archive(
name = "com_github_redis_hiredis",
build_file = "//bazel:BUILD.hiredis",
url = "https://github.com/redis/hiredis/archive/33152ad163a21f568fb40eeeb88b79365886b4ea.tar.gz",
sha256 = "9a91274dfd131111227b39ffa3cf7b446fbbd7ee2e5a94c8e7d8ad334b4ff255",
url = "https://github.com/redis/hiredis/archive/392de5d7f97353485df1237872cb682842e8d83f.tar.gz",
sha256 = "2101650d39a8f13293f263e9da242d2c6dee0cda08d343b2939ffe3d95cf3b8b",
patches = [
"//thirdparty/patches:hiredis-connect-rename.patch",
"//thirdparty/patches:hiredis-windows-msvc.patch",
"//thirdparty/patches:hiredis-windows-sigpipe.patch",
"//thirdparty/patches:hiredis-windows-sockets.patch",
"//thirdparty/patches:hiredis-windows-strerror.patch",
],
)

View file

@ -14,10 +14,6 @@
#include "asio.h"
#ifdef _WIN32
#include <win32fd.h>
#endif
#include "ray/util/logging.h"
RedisAsioClient::RedisAsioClient(boost::asio::io_service &io_service,
@ -37,7 +33,7 @@ RedisAsioClient::RedisAsioClient(boost::asio::io_service &io_service,
#ifdef _WIN32
SOCKET sock = SOCKET_ERROR;
WSAPROTOCOL_INFO pi;
if (WSADuplicateSocket(fh_get(c->fd), GetCurrentProcessId(), &pi) == 0) {
if (WSADuplicateSocket(c->fd, GetCurrentProcessId(), &pi) == 0) {
DWORD flag = WSA_FLAG_OVERLAPPED;
sock = WSASocket(pi.iAddressFamily, pi.iSocketType, pi.iProtocol, &pi, 0, flag);
}

View file

@ -1,28 +0,0 @@
diff --git test.c test.c
--- test.c
+++ 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);
--

View file

@ -14,11 +14,10 @@ diff --git sds.h sds.h
+#pragma pack(pop)
+#endif
diff --git net.c net.c
--- net.c
+++ net.c
@@ -52,1 +52,4 @@
#include <stdlib.h>
diff --git fmacros.h fmacros.h
--- fmacros.h
+++ fmacros.h
@@ -12,0 +12,3 @@
+#if defined(_MSC_VER) && !defined(__clang__) && !defined(strdup)
+#define strdup _strdup
+#endif

View file

@ -1,9 +0,0 @@
diff --git test.c test.c
--- test.c
+++ 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
--

View file

@ -1,58 +0,0 @@
diff --git hiredis.c hiredis.c
--- hiredis.c
+++ hiredis.c
@@ -620,1 +620,1 @@
- close(c->fd);
+ redisContextCloseFd(c);
@@ -648,1 +648,1 @@
- close(c->fd);
+ redisContextCloseFd(c);
diff --git net.h net.h
--- net.h
+++ net.h
@@ -44,1 +44,2 @@
+void redisContextCloseFd(redisContext *c);
int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout);
diff --git net.c net.c
--- net.c
+++ net.c
@@ -60,1 +60,1 @@
-static void redisContextCloseFd(redisContext *c) {
+void redisContextCloseFd(redisContext *c) {
@@ -102,24 +102,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;
}
--

View file

@ -1,17 +0,0 @@
diff --git hiredis.h hiredis.h
--- hiredis.h
+++ 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
--