Skip to content

Commit 9c28adc

Browse files
committed
remove thread-local variable
1 parent b5a1f30 commit 9c28adc

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Zend/zend_max_execution_timer.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,20 @@
3333
# define sigev_notify_thread_id _sigev_un._tid
3434
# endif
3535

36-
ZEND_TLS bool is_handler_set = false; // whether we have set up a timer in this thread
37-
3836
ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
3937
{
38+
pid_t pid = getpid();
39+
40+
if (EG(pid) == pid) {
41+
return;
42+
}
43+
4044
struct sigevent sev;
4145
sev.sigev_notify = SIGEV_THREAD_ID;
4246
sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer);
4347
sev.sigev_signo = SIGRTMIN;
4448
sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
4549

46-
// Now check to see if a we've already set a signal handler
47-
if(is_handler_set) {
48-
# ifdef MAX_EXECUTION_TIMERS_DEBUG
49-
fprintf(stderr, "A max execution timer was already configured and will not be configured again on thread %d\n", sev.sigev_notify_thread_id);
50-
# endif
51-
return;
52-
}
53-
5450
// Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727
5551
if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) {
5652
zend_strerror_noreturn(E_ERROR, errno, "Could not create timer");
@@ -63,7 +59,6 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
6359
# endif
6460

6561
sigaction(sev.sigev_signo, NULL, &EG(oldact));
66-
is_handler_set = true;
6762
}
6863
/* }}} */
6964

@@ -118,7 +113,6 @@ void zend_max_execution_timer_shutdown(void) /* {{{ */
118113
if(sigaction(SIGRTMIN, &ign_sigrtmin, NULL) < 0) {
119114
zend_strerror_noreturn(E_ERROR, errno, "Could not clear pending timer signal");
120115
}
121-
is_handler_set = false;
122116
}
123117
/* }}}} */
124118

0 commit comments

Comments
 (0)