Skip to content

Commit 58a0a04

Browse files
committed
cleanup API
1 parent 0a44aa0 commit 58a0a04

File tree

13 files changed

+37
-41
lines changed

13 files changed

+37
-41
lines changed

Zend/zend.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "zend_attributes.h"
3636
#include "zend_observer.h"
3737
#include "zend_fibers.h"
38-
#include "zend_timers.h"
38+
#include "zend_timer.h"
3939
#include "Optimizer/zend_optimizer.h"
4040

4141
static size_t global_map_ptr_last = 0;
@@ -822,16 +822,14 @@ static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */
822822
{
823823
zend_copy_ini_directives();
824824
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
825-
#ifdef ZEND_TIMERS
826-
zend_timers_startup();
827-
#endif
825+
zend_timer_init();
828826
}
829827
/* }}} */
830828

831829
static void zend_thread_shutdown_handler(void) { /* {{{ */
832830
zend_interned_strings_dtor();
833831
#ifdef ZEND_TIMERS
834-
zend_timers_shutdown();
832+
zend_timer_shutdown();
835833
#endif
836834
}
837835
/* }}} */

Zend/zend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "zend_smart_str_public.h"
4040
#include "zend_smart_string_public.h"
4141
#include "zend_signal.h"
42-
#include "zend_timers.h"
42+
#include "zend_timer.h"
4343

4444
#define zend_sprintf sprintf
4545

Zend/zend_execute_API.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ void init_executor(void) /* {{{ */
173173
EG(full_tables_cleanup) = 0;
174174
EG(vm_interrupt) = 0;
175175
EG(timed_out) = 0;
176-
#ifdef ZEND_TIMERS
177-
zend_timers_startup();
178-
#endif
179176

180177
EG(exception) = NULL;
181178
EG(prev_exception) = NULL;
@@ -198,6 +195,7 @@ void init_executor(void) /* {{{ */
198195
EG(num_errors) = 0;
199196
EG(errors) = NULL;
200197

198+
zend_timer_init();
201199
zend_fiber_init();
202200
zend_weakrefs_init();
203201

@@ -1441,7 +1439,7 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
14411439
return;
14421440
}
14431441
#elif defined(ZEND_TIMERS)
1444-
zend_timers_settime(seconds);
1442+
zend_timer_settime(seconds);
14451443

14461444
if (reset_signals) {
14471445
sigset_t sigset;
@@ -1521,7 +1519,7 @@ void zend_unset_timeout(void) /* {{{ */
15211519
tq_timer = NULL;
15221520
}
15231521
#elif ZEND_TIMERS
1524-
zend_timers_settime(0);
1522+
zend_timer_settime(0);
15251523
#elif defined(HAVE_SETITIMER)
15261524
if (EG(timeout_seconds)) {
15271525
struct itimerval no_timeout;

Zend/zend_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "zend_multibyte.h"
3737
#include "zend_multiply.h"
3838
#include "zend_arena.h"
39-
#include "zend_timers.h"
39+
#include "zend_timer.h"
4040

4141
/* Define ZTS if you want a thread-safe Zend */
4242
/*#undef ZTS*/

Zend/zend_timers.c renamed to Zend/zend_timer.c

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

36-
ZEND_API void zend_timers_startup(void) /* {{{ */
36+
ZEND_API void zend_timer_init(void) /* {{{ */
3737
{
3838
struct sigevent sev;
3939
sev.sigev_notify = SIGEV_THREAD_ID;
@@ -60,7 +60,7 @@ ZEND_API void zend_timers_startup(void) /* {{{ */
6060
}
6161
/* }}} */
6262

63-
void zend_timers_settime(zend_long seconds) /* {{{ }*/
63+
void zend_timer_settime(zend_long seconds) /* {{{ }*/
6464
{
6565
timer_t timer = EG(timer);
6666

@@ -78,7 +78,7 @@ void zend_timers_settime(zend_long seconds) /* {{{ }*/
7878
}
7979
/* }}} */
8080

81-
void zend_timers_shutdown(void) /* {{{ */
81+
void zend_timer_shutdown(void) /* {{{ */
8282
{
8383
timer_t timer = EG(timer);
8484
if (timer == (timer_t){0}) {

Zend/zend_timers.h renamed to Zend/zend_timer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#ifndef ZEND_TIMERS_H
18-
#define ZEND_TIMERS_H
17+
#ifndef ZEND_TIMER_H
18+
#define ZEND_TIMER_H
1919

2020
# ifdef ZEND_TIMERS
2121

2222
#include "zend_long.h"
2323

24-
ZEND_API void zend_timers_startup(void);
25-
void zend_timers_settime(zend_long seconds);
26-
void zend_timers_shutdown(void);
24+
/* Must be called after calls to fork() */
25+
ZEND_API void zend_timer_init(void);
26+
void zend_timer_settime(zend_long seconds);
27+
void zend_timer_shutdown(void);
2728

2829
# endif
2930
#endif

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ PHP_ADD_SOURCES(Zend, \
16341634
zend_closures.c zend_weakrefs.c zend_float.c zend_string.c zend_signal.c zend_generators.c \
16351635
zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \
16361636
zend_default_classes.c zend_inheritance.c zend_smart_str.c zend_cpuinfo.c zend_gdb.c \
1637-
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_timers.c \
1637+
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_timer.c \
16381638
Optimizer/zend_optimizer.c \
16391639
Optimizer/pass1.c \
16401640
Optimizer/pass3.c \

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4693,9 +4693,8 @@ static int accel_finish_startup(void)
46934693
zend_accel_error(ACCEL_LOG_WARNING, "Preloading failed to setuid(%d)", pw->pw_uid);
46944694
exit(1);
46954695
}
4696-
#ifdef ZEND_TIMERS
4697-
zend_timers_startup();
4698-
#endif
4696+
zend_timer_init();
4697+
46994698
in_child = 1;
47004699
} else { /* parent */
47014700
int status;

ext/pcntl/pcntl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
# define NSIG 32
5151
#endif
5252

53-
#include "Zend/zend_timers.h"
53+
#include "Zend/zend_timer.h"
5454

5555
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
5656
static PHP_GINIT_FUNCTION(pcntl);
@@ -534,9 +534,7 @@ PHP_FUNCTION(pcntl_fork)
534534
PCNTL_G(last_error) = errno;
535535
php_error_docref(NULL, E_WARNING, "Error %d", errno);
536536
} else if (id == 0) {
537-
#ifdef ZEND_TIMERS
538-
zend_timers_startup();
539-
#endif
537+
zend_timer_init();
540538
}
541539

542540
RETURN_LONG((zend_long) id);

sapi/apache2handler/sapi_apache2.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,13 +753,23 @@ static void php_apache_signal_init(apr_pool_t *pchild, server_rec *s)
753753
}
754754
#endif
755755

756+
#ifdef ZEND_TIMERS
757+
static void php_apache_timers_init(apr_pool_t *pchild, server_rec *s)
758+
{
759+
zend_timer_init();
760+
}
761+
#endif
762+
756763
void php_ap2_register_hook(apr_pool_t *p)
757764
{
758765
ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
759766
ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
760767
ap_hook_handler(php_handler, NULL, NULL, APR_HOOK_MIDDLE);
761768
#ifdef ZEND_SIGNALS
762769
ap_hook_child_init(php_apache_signal_init, NULL, NULL, APR_HOOK_MIDDLE);
770+
#endif
771+
#ifdef ZEND_TIMERS
772+
ap_hook_child_init(php_apache_timers_init, NULL, NULL, APR_HOOK_MIDDLE);
763773
#endif
764774
ap_hook_child_init(php_apache_child_init, NULL, NULL, APR_HOOK_MIDDLE);
765775
}

sapi/cgi/cgi_main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,10 +2053,7 @@ consult the installation file that came with this distribution, or visit \n\
20532053
sigaction(SIGQUIT, &old_quit, 0);
20542054
sigaction(SIGINT, &old_int, 0);
20552055
zend_signal_init();
2056-
2057-
#if ZEND_TIMERS
2058-
zend_timers_startup();
2059-
#endif
2056+
zend_timer_init();
20602057
break;
20612058
case -1:
20622059
perror("php (pre-forking)");

sapi/cli/php_cli_server.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#include "zend_execute.h"
6565
#include "zend_highlight.h"
6666
#include "zend_exceptions.h"
67-
#include "zend_timers.h"
67+
#include "zend_timer.h"
6868

6969
#include "php_getopt.h"
7070

@@ -2401,9 +2401,7 @@ static void php_cli_server_startup_workers(void) {
24012401
} else if (pid == SUCCESS) {
24022402
return;
24032403
} else {
2404-
#if ZEND_TIMERS
2405-
zend_timers_startup();
2406-
#endif
2404+
zend_timer_init();
24072405

24082406
php_cli_server_workers[php_cli_server_worker] = pid;
24092407
}

sapi/fpm/fpm/fpm_php.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "php_ini.h"
1212
#include "ext/standard/dl.h"
1313

14-
#include "zend_timers.h"
14+
#include "zend_timer.h"
1515

1616
#include "fastcgi.h"
1717

@@ -216,10 +216,7 @@ int fpm_php_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
216216
0 > fpm_php_set_allowed_clients(wp)) {
217217
return -1;
218218
}
219-
220-
#if ZEND_TIMERS
221-
zend_timers_startup();
222-
#endif
219+
zend_timer_init();
223220

224221
if (wp->limit_extensions) {
225222
/* Take ownership of limit_extensions. */

0 commit comments

Comments
 (0)