Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
08c3f0bc
Commit
08c3f0bc
authored
Dec 03, 2020
by
guybe7
Committed by
Oran Agra
Jan 12, 2021
Browse files
Modules: Fix an integer sign bug in moduleTimerHandler (#8131)
bug was introduced in
1a91a270
(cherry picked from commit
2f41a385
)
parent
3bf02ea7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
08c3f0bc
...
@@ -5443,8 +5443,11 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
...
@@ -5443,8 +5443,11 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
}
else
{
}
else
{
/* We call ustime() again instead of using the cached 'now' so that
/* We call ustime() again instead of using the cached 'now' so that
* 'next_period' isn't affected by the time it took to execute
* 'next_period' isn't affected by the time it took to execute
* previous calls to 'callback. */
* previous calls to 'callback.
next_period
=
(
expiretime
-
ustime
())
/
1000
;
/* Scale to milliseconds. */
* We need to cast 'expiretime' so that the compiler will not treat
* the difference as unsigned (Causing next_period to be huge) in
* case expiretime < ustime() */
next_period
=
((
long
long
)
expiretime
-
ustime
())
/
1000
;
/* Scale to milliseconds. */
break
;
break
;
}
}
}
}
...
@@ -5488,7 +5491,8 @@ RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisMod
...
@@ -5488,7 +5491,8 @@ RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisMod
/* We need to install the main event loop timer if it's not already
/* We need to install the main event loop timer if it's not already
* installed, or we may need to refresh its period if we just installed
* installed, or we may need to refresh its period if we just installed
* a timer that will expire sooner than any other else. */
* a timer that will expire sooner than any other else (i.e. the timer
* we just installed is the first timer in the Timers rax). */
if
(
aeTimer
!=
-
1
)
{
if
(
aeTimer
!=
-
1
)
{
raxIterator
ri
;
raxIterator
ri
;
raxStart
(
&
ri
,
Timers
);
raxStart
(
&
ri
,
Timers
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment