Skip to content

Commit be5b67b

Browse files
committed
arnaud's patch
1 parent 644ebc0 commit be5b67b

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

Zend/zend.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
801801
executor_globals->record_errors = false;
802802
executor_globals->num_errors = 0;
803803
executor_globals->errors = NULL;
804+
#ifdef ZEND_MAX_EXECUTION_TIMERS
805+
executor_globals->pid = 0;
806+
executor_globals->oldact = (struct sigaction){0};
807+
#endif
804808
}
805809
/* }}} */
806810

Zend/zend_max_execution_timer.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
5757

5858
void zend_max_execution_timer_settime(zend_long seconds) /* {{{ }*/
5959
{
60-
timer_t timer = EG(max_execution_timer_timer);
61-
62-
/* Timer doesn't anymore on request shutdown. */
63-
if (timer == (timer_t){0}) {
60+
/* Timer not initialized or shutdown. */
61+
if (!EG(pid)) {
6462
return;
6563
}
6664

65+
timer_t timer = EG(max_execution_timer_timer);
66+
6767
struct itimerspec its;
6868
its.it_value.tv_sec = seconds;
6969
its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0;
@@ -85,22 +85,15 @@ void zend_max_execution_timer_shutdown(void) /* {{{ */
8585
return;
8686
}
8787

88-
timer_t timer = EG(max_execution_timer_timer);
89-
if (timer == (timer_t){0}) {
90-
/* Don't trigger an error here because the timer may not be initialized when PHP fail early, and on threads created by PHP but not managed by it. */
91-
# ifdef MAX_EXECUTION_TIMERS_DEBUG
92-
fprintf(stderr, "Could not delete timer that has not been created on thread %d\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid));
93-
# endif
88+
EG(pid) = 0;
9489

95-
return;
96-
}
90+
timer_t timer = EG(max_execution_timer_timer);
9791

9892
# ifdef MAX_EXECUTION_TIMERS_DEBUG
9993
fprintf(stderr, "Deleting timer %#jx on thread %d...\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid));
10094
# endif
10195

10296
int err = timer_delete(timer);
103-
EG(max_execution_timer_timer) = (timer_t){0};
10497
if (err != 0) {
10598
zend_strerror_noreturn(E_ERROR, errno, "Could not delete timer");
10699
}

0 commit comments

Comments
 (0)