summaryrefslogtreecommitdiff
path: root/hiredis.c
diff options
context:
space:
mode:
authorMark Nunberg <mnunberg@haskalah.org>2019-04-10 08:28:36 -0400
committerMark Nunberg <mnunberg@haskalah.org>2019-04-10 08:36:06 -0400
commit4830786c84b96d2a2e95b49fba55a1548d9971e1 (patch)
tree646fa8a17462c35ceb4e1aac2d8a7de98afdceab /hiredis.c
parentca153fa4a8ae84021bdce7ec47e5339eef1d9212 (diff)
ensure that blocking timeout is set
Diffstat (limited to 'hiredis.c')
-rw-r--r--hiredis.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hiredis.c b/hiredis.c
index 5943306..6f60294 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -593,6 +593,7 @@ static redisContext *redisContextInit(const redisOptions *options) {
c->obuf = sdsempty();
c->reader = redisReaderCreate();
+ c->fd = REDIS_INVALID_FD;
if (c->obuf == NULL || c->reader == NULL) {
redisFree(c);
@@ -683,6 +684,9 @@ redisContext *redisConnectWithOptions(const redisOptions *options) {
// Unknown type - FIXME - FREE
return NULL;
}
+ if (options->timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) {
+ redisContextSetTimeout(c, *options->timeout);
+ }
return c;
}