Skip to content

Commit 6342f73

Browse files
Fix timer leak (#13027)
ts_resource() and php_request_startup() both eventually call zend_max_execution_timer_init(), which didn't have a guard to prevent recreating timers, thus resulting in leaking timers. This adds a guard to prevent the leak.
1 parent 2575e6b commit 6342f73

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Zend/zend_max_execution_timer.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535

3636
ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
3737
{
38+
pid_t pid = getpid();
39+
40+
if (EG(pid) == pid) {
41+
return;
42+
}
43+
3844
struct sigevent sev;
3945
sev.sigev_notify = SIGEV_THREAD_ID;
4046
sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer);
@@ -48,9 +54,9 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
4854

4955
EG(pid) = getpid();
5056

51-
# ifdef MAX_EXECUTION_TIMERS_DEBUG
57+
# ifdef MAX_EXECUTION_TIMERS_DEBUG
5258
fprintf(stderr, "Timer %#jx created on thread %d\n", (uintmax_t) EG(max_execution_timer_timer), sev.sigev_notify_thread_id);
53-
# endif
59+
# endif
5460

5561
sigaction(sev.sigev_signo, NULL, &EG(oldact));
5662
}

0 commit comments

Comments
 (0)