Commit c4ed06d9 authored by Geoff Garside's avatar Geoff Garside
Browse files

Fix incorrect "no route to host" errors.

If getaddrinfo(3) includes an AF_INET6 address before an AF_INET
address on a host with only IPv4 network connectivity then the
redisContextConnectTcp call would fail with "no route to host".

This commit fixes this issue by specifically handling the errno
EHOSTUNREACH error and entering another iteration of the addrinfo
loop. This will allow following AF_INET addresses to be attempted.
parent 3afe2585
......@@ -208,7 +208,10 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
if (redisSetBlocking(c,s,0) != REDIS_OK)
goto error;
if (connect(s,p->ai_addr,p->ai_addrlen) == -1) {
if (errno == EINPROGRESS && !blocking) {
if (errno == EHOSTUNREACH) {
close(s);
continue;
} else if (errno == EINPROGRESS && !blocking) {
/* This is ok. */
} else {
if (redisContextWaitReady(c,s,timeout) != REDIS_OK)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment