summaryrefslogtreecommitdiff
path: root/async_private.h
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-07-26 13:03:42 -0700
committerGitHub <noreply@github.com>2020-07-26 13:03:42 -0700
commitbe32bcdc8e84ae7dc091ceeffca2c5d4126f415c (patch)
treede0b76757b42d2811442826c7648366ea1a3c087 /async_private.h
parent38b5ae543f5c99eb4ccabbe277770fc6bc81226f (diff)
Minor refactor for scheduling an async timer. (#854)
Small change to the logic introduced in #839
Diffstat (limited to 'async_private.h')
-rw-r--r--async_private.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/async_private.h b/async_private.h
index e4a22ab..b9d23ff 100644
--- a/async_private.h
+++ b/async_private.h
@@ -54,14 +54,18 @@
} while(0);
static inline void refreshTimeout(redisAsyncContext *ctx) {
- 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);
+ #define REDIS_TIMER_ISSET(tvp) \
+ (tvp && ((tvp)->tv_sec || (tvp)->tv_usec))
+
+ #define REDIS_EL_TIMER(ac, tvp) \
+ if ((ac)->ev.scheduleTimer && REDIS_TIMER_ISSET(tvp)) { \
+ (ac)->ev.scheduleTimer((ac)->ev.data, *(tvp)); \
}
- } 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);
+
+ if (ctx->c.flags & REDIS_CONNECTED) {
+ REDIS_EL_TIMER(ctx, ctx->c.command_timeout);
+ } else {
+ REDIS_EL_TIMER(ctx, ctx->c.connect_timeout);
}
}