From 4830786c84b96d2a2e95b49fba55a1548d9971e1 Mon Sep 17 00:00:00 2001 From: Mark Nunberg Date: Wed, 10 Apr 2019 08:28:36 -0400 Subject: ensure that blocking timeout is set --- hiredis.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- cgit v1.2.3