From 79d9fec36d2decd96edff7347d30d29f776df9c8 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Fri, 14 Apr 2023 12:47:47 -0700 Subject: [PATCH] Don't attempt to set a timeout if we are in an error state. --- hiredis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hiredis.c b/hiredis.c index 26e1ed60a..72502eb7e 100644 --- a/hiredis.c +++ b/hiredis.c @@ -860,7 +860,9 @@ redisContext *redisConnectWithOptions(const redisOptions *options) { 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); }