summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Garside <geoff@geoffgarside.co.uk>2011-06-18 14:08:25 +0100
committerGeoff Garside <geoff@geoffgarside.co.uk>2011-06-18 14:08:25 +0100
commitc4ed06d90c2d25ccbb709b3d7c9c848aa732de66 (patch)
treecb8217db595ef6a4a0b516cc078deef09fb65394
parent3afe2585de94e82fd83c2b6a5534cf1e008dd083 (diff)
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.
-rw-r--r--net.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net.c b/net.c
index 9298d2d..ef3879c 100644
--- a/net.c
+++ b/net.c
@@ -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)