@@ -57,13 +57,13 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
57
57
58
58
void zend_max_execution_timer_settime (zend_long seconds ) /* {{{ }*/
59
59
{
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 )) {
64
62
return ;
65
63
}
66
64
65
+ timer_t timer = EG (max_execution_timer_timer );
66
+
67
67
struct itimerspec its ;
68
68
its .it_value .tv_sec = seconds ;
69
69
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) /* {{{ */
85
85
return ;
86
86
}
87
87
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 ;
94
89
95
- return ;
96
- }
90
+ timer_t timer = EG (max_execution_timer_timer );
97
91
98
92
# ifdef MAX_EXECUTION_TIMERS_DEBUG
99
93
fprintf (stderr , "Deleting timer %#jx on thread %d...\n" , (uintmax_t ) timer , (pid_t ) syscall (SYS_gettid ));
100
94
# endif
101
95
102
96
int err = timer_delete (timer );
103
- EG (max_execution_timer_timer ) = (timer_t ){0 };
104
97
if (err != 0 ) {
105
98
zend_strerror_noreturn (E_ERROR , errno , "Could not delete timer" );
106
99
}
0 commit comments