Skip to content

Commit

Permalink
hiredis: minimal IPv6 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jul 11, 2013
1 parent 5c5ebb0 commit 4735f03
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions deps/hiredis/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4735f03

Please sign in to comment.