@@ -57,13 +57,13 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
5757
5858void 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