From c4ed06d90c2d25ccbb709b3d7c9c848aa732de66 Mon Sep 17 00:00:00 2001 From: Geoff Garside Date: Sat, 18 Jun 2011 14:08:25 +0100 Subject: 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. --- net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'net.c') 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) -- cgit v1.2.3