mirror of
http://github.com/valkey-io/valkey
synced 2024-11-23 11:51:01 +00:00
hiredis: minimal IPv6 support.
This commit is contained in:
parent
5c5ebb0b9a
commit
4735f03c5a
8
deps/hiredis/net.c
vendored
8
deps/hiredis/net.c
vendored
@ -215,10 +215,18 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
|
|||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
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
|
||||||
|
* 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) {
|
||||||
|
hints.ai_family = AF_INET6;
|
||||||
if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
|
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) {
|
||||||
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)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user