Commit f12d52c1 authored by Mark Nunberg's avatar Mark Nunberg
Browse files

don't automatically use timeout for read/write timeout with...

connectWithTimeout()

The timeout value will still be used for I/O if using
connectWithOptions()
parent 5aa2397f
......@@ -685,7 +685,9 @@ redisContext *redisConnectWithOptions(const redisOptions *options) {
return NULL;
}
if (options->timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {
redisContextSetTimeout(c, *options->timeout);
if (!(options->options & REDIS_OPT_NORDWRTIMEOUT)) {
redisContextSetTimeout(c, *options->timeout);
}
}
return c;
}
......@@ -703,6 +705,7 @@ redisContext *redisConnectWithTimeout(const char *ip, int port, const struct tim
redisOptions options = {0};
REDIS_OPTIONS_SET_TCP(&options, ip, port);
options.timeout = &tv;
options.options |= REDIS_OPT_NORDWRTIMEOUT;
return redisConnectWithOptions(&options);
}
......
......@@ -133,6 +133,13 @@ struct redisSsl;
*/
#define REDIS_OPT_NOAUTOFREE 0x04
/**
* When using connectWithOptions, have the timeout only apply to the
* initial connect, not subsequent read/write attempts. This option
* is here to support the legacy connectWithTimeout()
*/
#define REDIS_OPT_NORDWRTIMEOUT 0x08
/* In Unix systems a file descriptor is a regular signed int, with -1
* representing an invalid descriptor. In Windows it is a SOCKET
* (32- or 64-bit unsigned integer depending on the architecture), where
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment