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.
This commit is contained in:
parent
45ee620e9c
commit
513931dfea
8
src/ae.c
8
src/ae.c
@ -464,6 +464,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
|
|||||||
if (!invert && fe->mask & mask & AE_READABLE) {
|
if (!invert && fe->mask & mask & AE_READABLE) {
|
||||||
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
|
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
|
||||||
fired++;
|
fired++;
|
||||||
|
fe = &eventLoop->events[fd]; /* Refresh in case of resize. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fire the writable event. */
|
/* 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
|
/* If we have to invert the call, fire the readable event now
|
||||||
* after the writable one. */
|
* after the writable one. */
|
||||||
if (invert && fe->mask & mask & AE_READABLE) {
|
if (invert) {
|
||||||
if (!fired || fe->wfileProc != fe->rfileProc) {
|
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);
|
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
|
||||||
fired++;
|
fired++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user