You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[EventLoop] Fix timers when using libevent-based loop.
Since a closure cannot destroy itself from inside its body, to prevent
PHP from raising the fatal error "Cannot destroy active lambda function"
when cancelling a periodic timer from inside its callback we previously
tried to postpone the call to event_free() on the affected libevent
timer resource at a later stage by queueing up timer resources to be
freed. This approach was quite awkward and eventually lead to complex
code, difficult to test and with other unexpected side effects such as
memory leaks in a couple of corner cases.
This new fix greatly reduces code complexity and makes it possible to
free up timer resources immediatly when cancelling a timer: we simply
keep a reference of our internal timer callback from inside itself so
that its refcount is still > 1 when calling event_free(), effectively
preventing PHP's garbage collector to kick in when the closure is
still active.
0 commit comments