aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-24 15:27:57 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-24 15:27:57 +0100
commite637e15306f18e27767941be4670b7091056ccc4 (patch)
treed920345044ccdf85dba159c23bc7005007dc0e05
parent41a84bc6248297a8a66f70a0991ba418b591fe07 (diff)
downloadrspamd-e637e15306f18e27767941be4670b7091056ccc4.tar.gz
rspamd-e637e15306f18e27767941be4670b7091056ccc4.zip
[Minor] Make socket non-blocking before connect()
Otherwise, in the case of error, socket may become invalid and we will get an incorrect error, i.e. "setsockopt(TCP_NODELAY): Invalid argument" instead of "Connection refused"
-rw-r--r--contrib/hiredis/net.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/contrib/hiredis/net.c b/contrib/hiredis/net.c
index 6aada0a6f..c208eb10d 100644
--- a/contrib/hiredis/net.c
+++ b/contrib/hiredis/net.c
@@ -367,6 +367,10 @@ addrretry:
goto error;
}
}
+ if (blocking && redisSetBlocking(c,1) != REDIS_OK)
+ goto error;
+ if (redisSetTcpNoDelay(c) != REDIS_OK)
+ goto error;
if (connect(s,p->ai_addr,p->ai_addrlen) == -1) {
if (errno == EHOSTUNREACH) {
redisContextCloseFd(c);
@@ -384,10 +388,6 @@ addrretry:
goto error;
}
}
- if (blocking && redisSetBlocking(c,1) != REDIS_OK)
- goto error;
- if (redisSetTcpNoDelay(c) != REDIS_OK)
- goto error;
c->flags |= REDIS_CONNECTED;
rv = REDIS_OK;