ensure that blocking timeout is set

This commit is contained in:
Mark Nunberg 2019-04-10 08:28:36 -04:00
parent ca153fa4a8
commit 4830786c84
1 changed files with 4 additions and 0 deletions

View File

@ -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;
}