Skip to content

Commit 83e8722

Browse files
committed
non-ZTS support
1 parent 2afb398 commit 83e8722

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Zend/zend_max_execution_timer.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@
3030

3131
static inline void zend_max_execution_timer_handler(void *arg)
3232
{
33+
#ifdef ZTS
3334
pthread_t *tid = (pthread_t *) arg;
3435
pthread_kill(*tid, ZEND_MAX_EXECUTION_TIMERS_SIGNAL);
36+
#else
37+
pid_t *pid = (pid_t *) arg;
38+
kill(*pid, ZEND_MAX_EXECUTION_TIMERS_SIGNAL);
39+
#endif
3540
}
3641

3742
static inline void zend_max_execution_timer_cancel(void *arg)
3843
{
39-
pthread_t *tid = (pthread_t *) arg;
40-
free(tid);
44+
free(arg);
4145
}
4246

4347
ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
@@ -58,10 +62,14 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
5862
EG(max_execution_timer_suspended) = 1;
5963

6064
# ifdef ZTS
61-
pthread_t lpid = pthread_self();
62-
pthread_t *tid = malloc(sizeof(pthread_t));
63-
memcpy(tid, &lpid, sizeof(pthread_t));
64-
dispatch_set_context(EG(max_execution_timer_timer), tid);
65+
pthread_t tid = pthread_self();
66+
pthread_t *ptid = malloc(sizeof(pthread_t));
67+
memcpy(ptid, &tid, sizeof(pthread_t));
68+
dispatch_set_context(EG(max_execution_timer_timer), ptid);
69+
#else
70+
pid_t *ppid = malloc(sizeof(pid_t));
71+
*ppid = pid;
72+
dispatch_set_context(EG(max_execution_timer_timer), ppid)
6573
# endif
6674

6775
dispatch_source_set_event_handler_f(EG(max_execution_timer_timer), zend_max_execution_timer_handler);

0 commit comments

Comments
 (0)