summaryrefslogtreecommitdiff
path: root/deps/hiredis
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-07-11 13:11:27 +0200
committerantirez <antirez@gmail.com>2013-07-11 13:11:27 +0200
commit4735f03c5ab4ee3518943576e2ebf8e4d463abcc (patch)
treea290f5d0ddbbfdf965876efc5454fcaab3b5b94d /deps/hiredis
parent5c5ebb0b9a70d428f982ed7aec5d5a60de605e42 (diff)
downloadredis-4735f03c5ab4ee3518943576e2ebf8e4d463abcc.tar.gz
hiredis: minimal IPv6 support.
Diffstat (limited to 'deps/hiredis')
-rw-r--r--deps/hiredis/net.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/deps/hiredis/net.c b/deps/hiredis/net.c
index 82ab2b468..b10eee2e5 100644
--- a/deps/hiredis/net.c
+++ b/deps/hiredis/net.c
@@ -215,9 +215,17 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
+ /* Try with IPv6 if no IPv4 address was found. We do it in this order since
+ * in a Redis client you can't afford to test if you have IPv6 connectivity
+ * as this would add latency to every connect. Otherwise a more sensible
+ * route could be: Use IPv6 if both addresses are available and there is IPv6
+ * connectivity. */
if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
- __redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
- return REDIS_ERR;
+ hints.ai_family = AF_INET6;
+ if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
+ __redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
+ return REDIS_ERR;
+ }
}
for (p = servinfo; p != NULL; p = p->ai_next) {
if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)