From 309e90638dac527077a2d81ceeebfba189251537 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 13 Feb 2015 10:58:35 +0800 Subject: [PATCH] Cleanup globals initialization --- Zend/zend.c | 18 +++--------- ext/standard/browscap.c | 3 +- main/main.c | 61 +++++++++++++---------------------------- sapi/fpm/fpm/fpm_main.c | 2 +- 4 files changed, 25 insertions(+), 59 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index 1bd70ab292..bfa732c0d0 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -466,22 +466,13 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */ { ZEND_TSRMLS_CACHE_UPDATE; + memset(executor_globals, 0, sizeof(*executor_globals)); + zend_startup_constants(); zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE); zend_init_rsrc_plist(); zend_init_exception_op(); - EG(lambda_count) = 0; - ZVAL_UNDEF(&EG(user_error_handler)); - ZVAL_UNDEF(&EG(user_exception_handler)); - EG(in_autoload) = NULL; - EG(current_execute_data) = NULL; - EG(current_module) = NULL; - EG(exit_status) = 0; -#if XPFPA_HAVE_CW - EG(saved_fpu_cw) = 0; -#endif - EG(saved_fpu_cw_ptr) = NULL; - EG(active) = 0; + EG(error_reporting) = E_ALL & ~E_NOTICE; } /* }}} */ @@ -661,8 +652,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) / ini_scanner_globals_ctor(&ini_scanner_globals); php_scanner_globals_ctor(&language_scanner_globals); zend_set_default_compile_time_values(); - ZVAL_UNDEF(&EG(user_error_handler)); - ZVAL_UNDEF(&EG(user_exception_handler)); + EG(error_reporting) = E_ALL & ~E_NOTICE; #endif zend_interned_strings_init(); diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 353e7cdccb..e88a09e883 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -311,8 +311,7 @@ PHP_MINIT_FUNCTION(browscap) /* {{{ */ char *browscap = INI_STR("browscap"); #ifdef ZTS - ts_allocate_id(&browscap_globals_id, sizeof(browser_data), - (ts_allocate_ctor) browscap_globals_ctor, NULL); + ts_allocate_id(&browscap_globals_id, sizeof(browser_data), (ts_allocate_ctor) browscap_globals_ctor, NULL); #endif /* ctor call not really needed for non-ZTS */ diff --git a/main/main.c b/main/main.c index d5d101ae55..d6b680c0be 100644 --- a/main/main.c +++ b/main/main.c @@ -1919,8 +1919,6 @@ static size_t php_output_wrapper(const char *str, size_t str_length) static void core_globals_ctor(php_core_globals *core_globals) { memset(core_globals, 0, sizeof(*core_globals)); - - php_startup_ticks(); } /* }}} */ #endif @@ -2035,9 +2033,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod char *php_os; zend_module_entry *module; #ifdef ZTS - zend_executor_globals *executor_globals; void ***tsrm_ls; - php_core_globals *core_globals; #endif #if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK)) @@ -2057,7 +2053,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod _CrtSetReportMode(_CRT_ASSERT, 0); #endif #else - php_os=PHP_OS; + php_os = PHP_OS; #endif #ifdef ZTS @@ -2081,27 +2077,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod php_output_startup(); - zuf.error_function = php_error_cb; - zuf.printf_function = php_printf; - zuf.write_function = php_output_wrapper; - zuf.fopen_function = php_fopen_wrapper_for_zend; - zuf.message_handler = php_message_handler_for_zend; - zuf.block_interruptions = sapi_module.block_interruptions; - zuf.unblock_interruptions = sapi_module.unblock_interruptions; - zuf.get_configuration_directive = php_get_configuration_directive_for_zend; - zuf.ticks_function = php_run_ticks; - zuf.on_timeout = php_on_timeout; - zuf.stream_open_function = php_stream_open_for_zend; - zuf.vspprintf_function = vspprintf; - zuf.vstrpprintf_function = vstrpprintf; - zuf.getenv_function = sapi_getenv; - zuf.resolve_path_function = php_resolve_path_for_zend; - zend_startup(&zuf, NULL); - #ifdef ZTS - executor_globals = ts_resource(executor_globals_id); ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); - core_globals = ts_resource(core_globals_id); + php_startup_ticks(); #ifdef PHP_WIN32 ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor); #endif @@ -2122,24 +2100,23 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod } } #endif - EG(bailout) = NULL; - EG(error_reporting) = E_ALL & ~E_NOTICE; - PG(header_is_being_sent) = 0; - SG(request_info).headers_only = 0; - SG(request_info).argv0 = NULL; - SG(request_info).argc=0; - SG(request_info).argv=(char **)NULL; - PG(connection_status) = PHP_CONNECTION_NORMAL; - PG(during_request_startup) = 0; - PG(last_error_message) = NULL; - PG(last_error_file) = NULL; - PG(last_error_lineno) = 0; - EG(error_handling) = EH_NORMAL; - EG(exception_class) = NULL; - PG(disable_functions) = NULL; - PG(disable_classes) = NULL; - EG(exception) = NULL; - EG(objects_store).object_buckets = NULL; + + zuf.error_function = php_error_cb; + zuf.printf_function = php_printf; + zuf.write_function = php_output_wrapper; + zuf.fopen_function = php_fopen_wrapper_for_zend; + zuf.message_handler = php_message_handler_for_zend; + zuf.block_interruptions = sapi_module.block_interruptions; + zuf.unblock_interruptions = sapi_module.unblock_interruptions; + zuf.get_configuration_directive = php_get_configuration_directive_for_zend; + zuf.ticks_function = php_run_ticks; + zuf.on_timeout = php_on_timeout; + zuf.stream_open_function = php_stream_open_for_zend; + zuf.vspprintf_function = vspprintf; + zuf.vstrpprintf_function = vstrpprintf; + zuf.getenv_function = sapi_getenv; + zuf.resolve_path_function = php_resolve_path_for_zend; + zend_startup(&zuf, NULL); #if HAVE_SETLOCALE setlocale(LC_CTYPE, ""); diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index c4ebc8bd3b..8dde3775c1 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -629,7 +629,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len) /* {{{ sapi_cgi_log_message */ -static void sapi_cgi_log_message(char *message) +static void sapi_cgi_log_message(char *message TSRMLS_DC) { zlog(ZLOG_NOTICE, "PHP message: %s", message); } -- 2.40.0