From 3f95fcdae4d13dd234aea1d1b7f0af50efb79219 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Fri, 14 Apr 2023 12:47:47 -0700 Subject: 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 26e1ed6..72502eb 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); } -- cgit v1.2.3