Compare commits
1 Commits
master
...
ipv6-unspe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4163e15771 |
16
net.c
16
net.c
@ -319,21 +319,19 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
|
|||||||
|
|
||||||
snprintf(_port, 6, "%d", port);
|
snprintf(_port, 6, "%d", port);
|
||||||
memset(&hints,0,sizeof(hints));
|
memset(&hints,0,sizeof(hints));
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
/* Try with IPv6 if no IPv4 address was found. We do it in this order since
|
/* We always check for both IPv4 and IPv6 addresses.
|
||||||
* in a Redis client you can't afford to test if you have IPv6 connectivity
|
* This is the only way it will work on v6-only hosts
|
||||||
* as this would add latency to every connect. Otherwise a more sensible
|
* (and will work on v4-only hosts as well).
|
||||||
* route could be: Use IPv6 if both addresses are available and there is IPv6
|
* In general we can rely on the order of addresses returned
|
||||||
* connectivity. */
|
* to avoid additional connect latency.
|
||||||
|
*/
|
||||||
if ((rv = getaddrinfo(c->tcp.host,_port,&hints,&servinfo)) != 0) {
|
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));
|
__redisSetError(c,REDIS_ERR_OTHER,gai_strerror(rv));
|
||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (p = servinfo; p != NULL; p = p->ai_next) {
|
for (p = servinfo; p != NULL; p = p->ai_next) {
|
||||||
addrretry:
|
addrretry:
|
||||||
if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
|
if ((s = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user