summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-03-31 10:11:26 +0200
committerantirez <antirez@gmail.com>2018-03-31 10:11:30 +0200
commitee982f4031771013bdbd12086c185fb53db45060 (patch)
tree8bad5b7b42130f69658d9234f33d077b35088cb2
parent4c11bc6cf067fb19bd6cb7517068c24543ca09d6 (diff)
downloadredis-ee982f4031771013bdbd12086c185fb53db45060.tar.gz
Modules Timer API: Wait at least 1 ms per iteration. Convert to ms.
-rw-r--r--src/module.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/module.c b/src/module.c
index 3022f8bbd..2a11b8507 100644
--- a/src/module.c
+++ b/src/module.c
@@ -4076,13 +4076,14 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
raxRemove(Timers,(unsigned char*)ri.key,ri.key_len,NULL);
zfree(timer);
} else {
- next_period = expiretime-now;
+ next_period = (expiretime-now)/1000; /* Scale to milliseconds. */
break;
}
}
raxStop(&ri);
/* Reschedule the next timer or cancel it. */
+ if (next_period <= 0) next_period = 1;
return (raxSize(Timers) > 0) ? next_period : AE_NOMORE;
}
@@ -4160,7 +4161,7 @@ int RM_GetTimerInfo(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remain
if (remaining) {
int64_t rem = ntohu64(id)-ustime();
if (rem < 0) rem = 0;
- *remaining = rem;
+ *remaining = rem/1000; /* Scale to milliseconds. */
}
if (data) *data = timer->data;
return REDISMODULE_OK;