Compare commits
1 Commits
master
...
ipv6-unspe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4163e15771 |
20
net.c
20
net.c
@ -319,20 +319,18 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
|
||||
|
||||
snprintf(_port, 6, "%d", port);
|
||||
memset(&hints,0,sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
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. */
|
||||
/* We always check for both IPv4 and IPv6 addresses.
|
||||
* This is the only way it will work on v6-only hosts
|
||||
* (and will work on v4-only hosts as well).
|
||||
* In general we can rely on the order of addresses returned
|
||||
* to avoid additional connect latency.
|
||||
*/
|
||||
if ((rv = getaddrinfo(c->tcp.host,_port,&hints,&servinfo)) != 0) {
|
||||
hints.ai_family = AF_INET6;
|
||||
if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
|
||||
__redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
|
||||
return REDIS_ERR;
|
||||
}
|
||||
__redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
|
||||
return REDIS_ERR;
|
||||
}
|
||||
for (p = servinfo; p != NULL; p = p->ai_next) {
|
||||
addrretry:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user