diff options
author | Geoff Garside <geoff@geoffgarside.co.uk> | 2011-06-18 14:08:25 +0100 |
---|---|---|
committer | Geoff Garside <geoff@geoffgarside.co.uk> | 2011-06-18 14:08:25 +0100 |
commit | c4ed06d90c2d25ccbb709b3d7c9c848aa732de66 (patch) | |
tree | cb8217db595ef6a4a0b516cc078deef09fb65394 | |
parent | 3afe2585de94e82fd83c2b6a5534cf1e008dd083 (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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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) |