summaryrefslogtreecommitdiff
path: root/async_private.h
diff options
context:
space:
mode:
authorAlessio M <masariello@gmail.com>2020-09-04 09:31:47 +0100
committerAlessio M <masariello@gmail.com>2020-09-04 09:31:47 +0100
commitd7b1d21e807f8a90a086b2ef5cea9b707d4cc858 (patch)
tree748b00a48a8b625f1dca22ae4cc5721ab7de87c5 /async_private.h
parent07c3618ffe7912c2ebc589ea45501c687a19cf2c (diff)
parentfb0e6c0dd9affd5728c6e0a6423f5dcb7b207947 (diff)
Merge branch 'master' of github.com:redis/hiredis
Diffstat (limited to 'async_private.h')
-rw-r--r--async_private.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/async_private.h b/async_private.h
index d0133ae..b9d23ff 100644
--- a/async_private.h
+++ b/async_private.h
@@ -54,15 +54,18 @@
} 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);
- // }
+ #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)); \
+ }
+
+ if (ctx->c.flags & REDIS_CONNECTED) {
+ REDIS_EL_TIMER(ctx, ctx->c.command_timeout);
+ } else {
+ REDIS_EL_TIMER(ctx, ctx->c.connect_timeout);
}
}