Skip to content

Commit e20be74

Browse files
committed
better timer creation
1 parent a2cc8a1 commit e20be74

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

Zend/zend.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,6 @@ zend_result zend_post_startup(void) /* {{{ */
11041104
executor_globals_ctor(executor_globals);
11051105
global_persistent_list = &EG(persistent_list);
11061106
zend_copy_ini_directives();
1107-
1108-
# ifdef ZEND_TIMER
1109-
zend_timer_create();
1110-
# endif
11111107
#else
11121108
global_map_ptr_last = CG(map_ptr_last);
11131109
#endif

Zend/zend_execute_API.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ void init_executor(void) /* {{{ */
173173
EG(full_tables_cleanup) = 0;
174174
EG(vm_interrupt) = 0;
175175
EG(timed_out) = 0;
176+
#ifdef ZEND_TIMER
177+
zend_timer_create();
178+
/*EG(timer) = (timer_t){0};
179+
EG(oldact) = (struct sigaction){0};*/
180+
#endif
176181

177182
EG(exception) = NULL;
178183
EG(prev_exception) = NULL;
@@ -199,11 +204,6 @@ void init_executor(void) /* {{{ */
199204
zend_weakrefs_init();
200205

201206
EG(active) = 1;
202-
203-
#ifdef ZEND_TIMER
204-
memset(EG(timer), 0, sizeof(*EG(timer)));
205-
memset(&EG(oldact), 0, sizeof(EG(oldact)));
206-
#endif
207207
}
208208
/* }}} */
209209

Zend/zend_timer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ZEND_API void zend_timer_settime(zend_long seconds) /* {{{ }*/
6565
{
6666
timer_t timer = EG(timer);
6767

68-
if (timer == 0) {
68+
if (timer == (timer_t){0}) {
6969
zend_error_noreturn(E_ERROR, "Timer not created");
7070
}
7171

@@ -86,7 +86,7 @@ ZEND_API void zend_timer_settime(zend_long seconds) /* {{{ }*/
8686
ZEND_API void zend_timer_delete(void) /* {{{ */
8787
{
8888
timer_t timer = EG(timer);
89-
if (timer == 0) {
89+
if (timer == (timer_t){0}) {
9090
/* 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. */
9191
# ifdef TIMER_DEBUG
9292
fprintf(stderr, "Could not delete timer that has not been created on thread %d\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid));
@@ -100,7 +100,7 @@ ZEND_API void zend_timer_delete(void) /* {{{ */
100100
# endif
101101

102102
int err = timer_delete(timer);
103-
EG(timer) = 0;
103+
EG(timer) = (timer_t){0};
104104
if (err != 0) {
105105
zend_strerror_noreturn(E_ERROR, errno, "Could not delete timer");
106106
}

0 commit comments

Comments
 (0)