diff options
author | Mark Nunberg <mnunberg@haskalah.org> | 2019-04-10 08:28:36 -0400 |
---|---|---|
committer | Mark Nunberg <mnunberg@haskalah.org> | 2019-04-10 08:36:06 -0400 |
commit | 4830786c84b96d2a2e95b49fba55a1548d9971e1 (patch) | |
tree | 646fa8a17462c35ceb4e1aac2d8a7de98afdceab | |
parent | ca153fa4a8ae84021bdce7ec47e5339eef1d9212 (diff) |
ensure that blocking timeout is set
-rw-r--r-- | hiredis.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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; } |