summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-03-12 12:59:44 +0100
committerantirez <antirez@gmail.com>2020-03-12 13:24:30 +0100
commit513931dfea68ae866b91b197ca7fc0e9d845bb0a (patch)
tree967089a4f33cfcdbadca490d9563477ae13e0cd1
parent45ee620e9cba853bcf06f7bac34e6d8b0bcc8661 (diff)
downloadredis-513931dfea68ae866b91b197ca7fc0e9d845bb0a.tar.gz
ae.c: fix crash when resizing the event loop.
See #6964. The root cause is that the event loop may be resized from an event callback itself, causing the event pointer to be invalid.
-rw-r--r--src/ae.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ae.c b/src/ae.c
index d2248fe5c..1bf6cbfbf 100644
--- a/src/ae.c
+++ b/src/ae.c
@@ -464,6 +464,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
if (!invert && fe->mask & mask & AE_READABLE) {
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
fired++;
+ fe = &eventLoop->events[fd]; /* Refresh in case of resize. */
}
/* Fire the writable event. */
@@ -476,8 +477,11 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
/* If we have to invert the call, fire the readable event now
* after the writable one. */
- if (invert && fe->mask & mask & AE_READABLE) {
- if (!fired || fe->wfileProc != fe->rfileProc) {
+ if (invert) {
+ fe = &eventLoop->events[fd]; /* Refresh in case of resize. */
+ if ((fe->mask & mask & AE_READABLE) &&
+ (!fired || fe->wfileProc != fe->rfileProc))
+ {
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
fired++;
}