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
2435341d
Commit
2435341d
authored
May 14, 2020
by
Madelyn Olson
Committed by
antirez
May 15, 2020
Browse files
Added a refcount on timer events to prevent deletion of recursive timer calls
parent
80c906bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ae.c
View file @
2435341d
...
...
@@ -238,6 +238,7 @@ long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
te
->
clientData
=
clientData
;
te
->
prev
=
NULL
;
te
->
next
=
eventLoop
->
timeEventHead
;
te
->
refcount
=
0
;
if
(
te
->
next
)
te
->
next
->
prev
=
te
;
eventLoop
->
timeEventHead
=
te
;
...
...
@@ -316,6 +317,13 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
/* Remove events scheduled for deletion. */
if
(
te
->
id
==
AE_DELETED_EVENT_ID
)
{
aeTimeEvent
*
next
=
te
->
next
;
/* If a reference exists for this timer event,
* don't free it. This is currently incremented
* for recursive timerProc calls */
if
(
te
->
refcount
)
{
te
=
next
;
continue
;
}
if
(
te
->
prev
)
te
->
prev
->
next
=
te
->
next
;
else
...
...
@@ -345,7 +353,9 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
int
retval
;
id
=
te
->
id
;
te
->
refcount
++
;
retval
=
te
->
timeProc
(
eventLoop
,
id
,
te
->
clientData
);
te
->
refcount
--
;
processed
++
;
if
(
retval
!=
AE_NOMORE
)
{
aeAddMillisecondsToNow
(
retval
,
&
te
->
when_sec
,
&
te
->
when_ms
);
...
...
src/ae.h
View file @
2435341d
...
...
@@ -86,6 +86,8 @@ typedef struct aeTimeEvent {
void
*
clientData
;
struct
aeTimeEvent
*
prev
;
struct
aeTimeEvent
*
next
;
int
refcount
;
/* refcount to prevent timer events from being
* freed in recursive time event calls. */
}
aeTimeEvent
;
/* A fired event */
...
...
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