summaryrefslogtreecommitdiff
path: root/async_private.h
diff options
context:
space:
mode:
authorvalentinogeron <valentino@redislabs.com>2020-07-26 22:32:27 +0300
committerGitHub <noreply@github.com>2020-07-26 12:32:27 -0700
commit38b5ae543f5c99eb4ccabbe277770fc6bc81226f (patch)
tree9377e746a4fce5ab34730f16c06c11db3bbfb839 /async_private.h
parent3bb985314d0563857c84beef0097ffc8de2d9438 (diff)
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
Diffstat (limited to 'async_private.h')
-rw-r--r--async_private.h17
1 files changed, 8 insertions, 9 deletions
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);
}
}