Don't attempt to set a timeout if we are in an error state.

This commit is contained in:
michael-grunder 2023-04-14 12:47:47 -07:00 committed by Michael Grunder
parent aacb84b8d4
commit 3f95fcdae4

View File

@ -860,7 +860,9 @@ redisContext *redisConnectWithOptions(const redisOptions *options) {
return NULL; return NULL;
} }
if (options->command_timeout != NULL && (c->flags & REDIS_BLOCK) && c->fd != REDIS_INVALID_FD) { if (c->err == 0 && c->fd != REDIS_INVALID_FD &&
options->command_timeout != NULL && (c->flags & REDIS_BLOCK))
{
redisContextSetTimeout(c, *options->command_timeout); redisContextSetTimeout(c, *options->command_timeout);
} }