From 38b5ae543f5c99eb4ccabbe277770fc6bc81226f Mon Sep 17 00:00:00 2001 From: valentinogeron Date: Sun, 26 Jul 2020 22:32:27 +0300 Subject: add a command_timeout to redisContextOptions (#839) Add an additional timeout so the user has a convenient way of controlling distinct connect and command timeouts --- async_private.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'async_private.h') diff --git a/async_private.h b/async_private.h index d0133ae..e4a22ab 100644 --- a/async_private.h +++ b/async_private.h @@ -54,15 +54,14 @@ } while(0); static inline void refreshTimeout(redisAsyncContext *ctx) { - if (ctx->c.timeout && ctx->ev.scheduleTimer && - (ctx->c.timeout->tv_sec || ctx->c.timeout->tv_usec)) { - ctx->ev.scheduleTimer(ctx->ev.data, *ctx->c.timeout); - // } else { - // printf("Not scheduling timer.. (tmo=%p)\n", ctx->c.timeout); - // if (ctx->c.timeout){ - // printf("tv_sec: %u. tv_usec: %u\n", ctx->c.timeout->tv_sec, - // ctx->c.timeout->tv_usec); - // } + if (!(ctx->c.flags & REDIS_CONNECTED)) { + if (ctx->c.connect_timeout && ctx->ev.scheduleTimer && + (ctx->c.connect_timeout->tv_sec || ctx->c.connect_timeout->tv_usec)) { + ctx->ev.scheduleTimer(ctx->ev.data, *ctx->c.connect_timeout); + } + } else if (ctx->c.command_timeout && ctx->ev.scheduleTimer && + (ctx->c.command_timeout->tv_sec || ctx->c.command_timeout->tv_usec)) { + ctx->ev.scheduleTimer(ctx->ev.data, *ctx->c.command_timeout); } } -- cgit v1.2.3