diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-24 15:27:57 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-24 15:27:57 +0100 |
commit | e637e15306f18e27767941be4670b7091056ccc4 (patch) | |
tree | d920345044ccdf85dba159c23bc7005007dc0e05 /contrib | |
parent | 41a84bc6248297a8a66f70a0991ba418b591fe07 (diff) | |
download | rspamd-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"
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/hiredis/net.c | 8 |
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; |