diff options
Diffstat (limited to 'main/main.c')
| -rw-r--r-- | main/main.c | 428 |
1 files changed, 232 insertions, 196 deletions
diff --git a/main/main.c b/main/main.c index d68cb6eca4..ee422db52f 100644 --- a/main/main.c +++ b/main/main.c @@ -12,14 +12,12 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Andi Gutmans <andi@zend.com> | + | Authors: Andi Gutmans <andi@php.net> | | Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Zeev Suraski <zeev@zend.com> | + | Zeev Suraski <zeev@php.net> | +----------------------------------------------------------------------+ */ -/* $Id$ */ - /* {{{ includes */ @@ -53,6 +51,7 @@ #include "php_ini.h" #include "php_globals.h" #include "php_main.h" +#include "php_syslog.h" #include "fopen_wrappers.h" #include "ext/standard/php_standard.h" #include "ext/standard/php_string.h" @@ -148,6 +147,143 @@ static char *get_safe_charset_hint(void) { /* {{{ PHP_INI_MH */ +static PHP_INI_MH(OnSetFacility) +{ + const char *facility = ZSTR_VAL(new_value); + +#ifdef LOG_AUTH + if (!strcmp(facility, "LOG_AUTH") || !strcmp(facility, "auth") || !strcmp(facility, "security")) { + PG(syslog_facility) = LOG_AUTH; + return SUCCESS; + } +#endif +#ifdef LOG_AUTHPRIV + if (!strcmp(facility, "LOG_AUTHPRIV") || !strcmp(facility, "authpriv")) { + PG(syslog_facility) = LOG_AUTHPRIV; + return SUCCESS; + } +#endif +#ifdef LOG_CRON + if (!strcmp(facility, "LOG_CRON") || !strcmp(facility, "cron")) { + PG(syslog_facility) = LOG_CRON; + return SUCCESS; + } +#endif +#ifdef LOG_DAEMON + if (!strcmp(facility, "LOG_DAEMON") || !strcmp(facility, "daemon")) { + PG(syslog_facility) = LOG_DAEMON; + return SUCCESS; + } +#endif +#ifdef LOG_FTP + if (!strcmp(facility, "LOG_FTP") || !strcmp(facility, "ftp")) { + PG(syslog_facility) = LOG_FTP; + return SUCCESS; + } +#endif +#ifdef LOG_KERN + if (!strcmp(facility, "LOG_KERN") || !strcmp(facility, "kern")) { + PG(syslog_facility) = LOG_KERN; + return SUCCESS; + } +#endif +#ifdef LOG_LPR + if (!strcmp(facility, "LOG_LPR") || !strcmp(facility, "lpr")) { + PG(syslog_facility) = LOG_LPR; + return SUCCESS; + } +#endif +#ifdef LOG_MAIL + if (!strcmp(facility, "LOG_MAIL") || !strcmp(facility, "mail")) { + PG(syslog_facility) = LOG_MAIL; + return SUCCESS; + } +#endif +#ifdef LOG_INTERNAL_MARK + if (!strcmp(facility, "LOG_INTERNAL_MARK") || !strcmp(facility, "mark")) { + PG(syslog_facility) = LOG_INTERNAL_MARK; + return SUCCESS; + } +#endif +#ifdef LOG_NEWS + if (!strcmp(facility, "LOG_NEWS") || !strcmp(facility, "news")) { + PG(syslog_facility) = LOG_NEWS; + return SUCCESS; + } +#endif +#ifdef LOG_SYSLOG + if (!strcmp(facility, "LOG_SYSLOG") || !strcmp(facility, "syslog")) { + PG(syslog_facility) = LOG_SYSLOG; + return SUCCESS; + } +#endif +#ifdef LOG_USER + if (!strcmp(facility, "LOG_USER") || !strcmp(facility, "user")) { + PG(syslog_facility) = LOG_USER; + return SUCCESS; + } +#endif +#ifdef LOG_UUCP + if (!strcmp(facility, "LOG_UUCP") || !strcmp(facility, "uucp")) { + PG(syslog_facility) = LOG_UUCP; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL0 + if (!strcmp(facility, "LOG_LOCAL0") || !strcmp(facility, "local0")) { + PG(syslog_facility) = LOG_LOCAL0; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL1 + if (!strcmp(facility, "LOG_LOCAL1") || !strcmp(facility, "local1")) { + PG(syslog_facility) = LOG_LOCAL1; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL2 + if (!strcmp(facility, "LOG_LOCAL2") || !strcmp(facility, "local2")) { + PG(syslog_facility) = LOG_LOCAL2; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL3 + if (!strcmp(facility, "LOG_LOCAL3") || !strcmp(facility, "local3")) { + PG(syslog_facility) = LOG_LOCAL3; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL4 + if (!strcmp(facility, "LOG_LOCAL4") || !strcmp(facility, "local4")) { + PG(syslog_facility) = LOG_LOCAL4; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL5 + if (!strcmp(facility, "LOG_LOCAL5") || !strcmp(facility, "local5")) { + PG(syslog_facility) = LOG_LOCAL5; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL6 + if (!strcmp(facility, "LOG_LOCAL6") || !strcmp(facility, "local6")) { + PG(syslog_facility) = LOG_LOCAL6; + return SUCCESS; + } +#endif +#ifdef LOG_LOCAL7 + if (!strcmp(facility, "LOG_LOCAL7") || !strcmp(facility, "local7")) { + PG(syslog_facility) = LOG_LOCAL7; + return SUCCESS; + } +#endif + + return FAILURE; +} +/* }}} */ + +/* {{{ PHP_INI_MH + */ static PHP_INI_MH(OnSetPrecision) { zend_long i; @@ -184,14 +320,36 @@ static PHP_INI_MH(OnSetSerializePrecision) static PHP_INI_MH(OnChangeMemoryLimit) { if (new_value) { - PG(memory_limit) = zend_atol(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value)); + PG(memory_limit) = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); } else { - PG(memory_limit) = 1<<30; /* effectively, no limit */ + PG(memory_limit) = Z_L(1)<<30; /* effectively, no limit */ } return zend_set_memory_limit(PG(memory_limit)); } /* }}} */ +/* {{{ PHP_INI_MH + */ +static PHP_INI_MH(OnSetLogFilter) +{ + const char *filter = ZSTR_VAL(new_value); + + if (!strcmp(filter, "all")) { + PG(syslog_filter) = PHP_SYSLOG_FILTER_ALL; + return SUCCESS; + } + if (!strcmp(filter, "no-ctrl")) { + PG(syslog_filter) = PHP_SYSLOG_FILTER_NO_CTRL; + return SUCCESS; + } + if (!strcmp(filter, "ascii")) { + PG(syslog_filter) = PHP_SYSLOG_FILTER_ASCII; + return SUCCESS; + } + + return FAILURE; +} +/* }}} */ /* {{{ php_disable_functions */ @@ -335,7 +493,7 @@ static PHP_INI_MH(OnUpdateTimeout) /* {{{ php_get_display_errors_mode() helper function */ -static int php_get_display_errors_mode(char *value, int value_length) +static int php_get_display_errors_mode(char *value, size_t value_length) { int mode; @@ -368,7 +526,7 @@ static int php_get_display_errors_mode(char *value, int value_length) */ static PHP_INI_MH(OnUpdateDisplayErrors) { - PG(display_errors) = (zend_bool) php_get_display_errors_mode(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value)); + PG(display_errors) = (zend_bool) php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); return SUCCESS; } @@ -378,15 +536,16 @@ static PHP_INI_MH(OnUpdateDisplayErrors) */ static PHP_INI_DISP(display_errors_mode) { - int mode, tmp_value_length, cgi_or_cli; + int mode, cgi_or_cli; + size_t tmp_value_length; char *tmp_value; if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : NULL ); - tmp_value_length = (int)(ini_entry->orig_value? ZSTR_LEN(ini_entry->orig_value) : 0); + tmp_value_length = (ini_entry->orig_value? ZSTR_LEN(ini_entry->orig_value) : 0); } else if (ini_entry->value) { tmp_value = ZSTR_VAL(ini_entry->value); - tmp_value_length = (int)ZSTR_LEN(ini_entry->value); + tmp_value_length = ZSTR_LEN(ini_entry->value); } else { tmp_value = NULL; tmp_value_length = 0; @@ -635,6 +794,9 @@ PHP_INI_BEGIN() #ifdef PHP_WIN32 STD_PHP_INI_BOOLEAN("windows.show_crt_warning", "0", PHP_INI_ALL, OnUpdateBool, windows_show_crt_warning, php_core_globals, core_globals) #endif + STD_PHP_INI_ENTRY("syslog.facility", "LOG_USER", PHP_INI_SYSTEM, OnSetFacility, syslog_facility, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("syslog.ident", "php", PHP_INI_SYSTEM, OnUpdateString, syslog_ident, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("syslog.filter", "no-ctrl", PHP_INI_ALL, OnSetLogFilter, syslog_filter, php_core_globals, core_globals) PHP_INI_END() /* }}} */ @@ -1006,10 +1168,10 @@ PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *para php_error_docref2(NULL, param1, param2, E_WARNING, "%s", strerror(errno)); } else { char buf[PHP_WIN32_ERROR_MSG_BUFFER_SIZE + 1]; - int buf_len; + size_t buf_len; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buf, PHP_WIN32_ERROR_MSG_BUFFER_SIZE, NULL); - buf_len = (int)strlen(buf); + buf_len = strlen(buf); if (buf_len >= 2) { buf[buf_len - 1] = '\0'; buf[buf_len - 2] = '\0'; @@ -1052,29 +1214,8 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u display = 1; } - /* store the error if it has changed */ - if (display) { - if (PG(last_error_message)) { - char *s = PG(last_error_message); - PG(last_error_message) = NULL; - free(s); - } - if (PG(last_error_file)) { - char *s = PG(last_error_file); - PG(last_error_file) = NULL; - free(s); - } - if (!error_filename) { - error_filename = "Unknown"; - } - PG(last_error_type) = type; - PG(last_error_message) = strdup(buffer); - PG(last_error_file) = strdup(error_filename); - PG(last_error_lineno) = error_lineno; - } - - /* according to error handling mode, suppress error, throw exception or show it */ - if (EG(error_handling) != EH_NORMAL) { + /* according to error handling mode, throw exception or show it */ + if (EG(error_handling) == EH_THROW) { switch (type) { case E_ERROR: case E_CORE_ERROR: @@ -1096,7 +1237,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u /* throw an exception if we are in EH_THROW mode * but DO NOT overwrite a pending exception */ - if (EG(error_handling) == EH_THROW && !EG(exception)) { + if (!EG(exception)) { zend_throw_error_exception(EG(exception_class), buffer, 0, type); } efree(buffer); @@ -1104,6 +1245,27 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u } } + /* store the error if it has changed */ + if (display) { + if (PG(last_error_message)) { + char *s = PG(last_error_message); + PG(last_error_message) = NULL; + free(s); + } + if (PG(last_error_file)) { + char *s = PG(last_error_file); + PG(last_error_file) = NULL; + free(s); + } + if (!error_filename) { + error_filename = "Unknown"; + } + PG(last_error_type) = type; + PG(last_error_message) = strdup(buffer); + PG(last_error_file) = strdup(error_filename); + PG(last_error_lineno) = error_lineno; + } + /* display/log the error if necessary */ if (display && (EG(error_reporting) & type || (type & E_CORE)) && (PG(log_errors) || PG(display_errors) || (!module_initialized))) { @@ -1159,14 +1321,14 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, buffer, GetCommandLine()); } #endif - spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); + spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, buffer, error_filename, error_lineno); php_log_err_with_severity(log_buffer, syslog_type_int); efree(log_buffer); } if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) { if (PG(xmlrpc_errors)) { - php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno); + php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno); } else { char *prepend_string = INI_STR("error_prepend_string"); char *append_string = INI_STR("error_append_string"); @@ -1174,22 +1336,22 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u if (PG(html_errors)) { if (type == E_ERROR || type == E_PARSE) { zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint()); - php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string)); zend_string_free(buf); } else { - php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } else { /* Write CLI/CGI errors to stderr if display_errors = "stderr" */ if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg")) && PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR ) { - fprintf(stderr, "%s: %s in %s on line %u\n", error_type_str, buffer, error_filename, error_lineno); + fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, buffer, error_filename, error_lineno); #ifdef PHP_WIN32 fflush(stderr); #endif } else { - php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } } @@ -1209,7 +1371,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u trigger_break=0; break; } - zend_output_debug_string(trigger_break, "%s(%d) : %s - %s", error_filename, error_lineno, error_type_str, buffer); + zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s - %s", error_filename, error_lineno, error_type_str, buffer); } #endif } @@ -1365,7 +1527,7 @@ PHP_FUNCTION(set_time_limit) } else { RETVAL_FALSE; } - zend_string_release(key); + zend_string_release_ex(key, 0); efree(new_timeout_str); } /* }}} */ @@ -1450,7 +1612,7 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h } /* }}} */ -static zend_string *php_resolve_path_for_zend(const char *filename, int filename_len) /* {{{ */ +static zend_string *php_resolve_path_for_zend(const char *filename, size_t filename_len) /* {{{ */ { return php_resolve_path(filename, filename_len, PG(include_path)); } @@ -1506,17 +1668,17 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void if (message==ZMSG_MEMORY_LEAK_DETECTED) { zend_leak_info *t = (zend_leak_info *) data; - snprintf(memory_leak_buf, 512, "%s(%d) : Freeing " ZEND_ADDR_FMT " (%zu bytes), script=%s\n", t->filename, t->lineno, (size_t)t->addr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); + snprintf(memory_leak_buf, 512, "%s(%" PRIu32 ") : Freeing " ZEND_ADDR_FMT " (%zu bytes), script=%s\n", t->filename, t->lineno, (size_t)t->addr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); if (t->orig_filename) { char relay_buf[512]; - snprintf(relay_buf, 512, "%s(%d) : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno); + snprintf(relay_buf, 512, "%s(%" PRIu32 ") : Actual location (location was relayed)\n", t->orig_filename, t->orig_lineno); strlcat(memory_leak_buf, relay_buf, sizeof(memory_leak_buf)); } } else { unsigned long leak_count = (zend_uintptr_t) data; - snprintf(memory_leak_buf, 512, "Last leak repeated %ld time%s\n", leak_count, (leak_count>1?"s":"")); + snprintf(memory_leak_buf, 512, "Last leak repeated %lu time%s\n", leak_count, (leak_count>1?"s":"")); } # if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); @@ -1587,39 +1749,8 @@ static void sigchld_handler(int apar) /* }}} */ #endif -/* {{{ php_start_sapi() - */ -static int php_start_sapi(void) -{ - int retval = SUCCESS; - - if(!SG(sapi_started)) { - zend_try { - PG(during_request_startup) = 1; - - /* initialize global variables */ - PG(modules_activated) = 0; - PG(header_is_being_sent) = 0; - PG(connection_status) = PHP_CONNECTION_NORMAL; - - zend_activate(); - zend_set_timeout(EG(timeout_seconds), 1); - zend_activate_modules(); - PG(modules_activated)=1; - } zend_catch { - retval = FAILURE; - } zend_end_try(); - - SG(sapi_started) = 1; - } - return retval; -} - -/* }}} */ - /* {{{ php_request_startup */ -#ifndef APACHE_HOOKS int php_request_startup(void) { int retval = SUCCESS; @@ -1701,61 +1832,6 @@ int php_request_startup(void) return retval; } -# else -int php_request_startup(void) -{ - int retval = SUCCESS; - - zend_interned_strings_activate(); - -#if PHP_SIGCHILD - signal(SIGCHLD, sigchld_handler); -#endif - - if (php_start_sapi() == FAILURE) { - return FAILURE; - } - - php_output_activate(); - sapi_activate(); - php_hash_environment(); - - zend_try { - PG(during_request_startup) = 1; - if (PG(expose_php)) { - sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); - } - } zend_catch { - retval = FAILURE; - } zend_end_try(); - - return retval; -} -# endif -/* }}} */ - -/* {{{ php_request_startup_for_hook - */ -int php_request_startup_for_hook(void) -{ - int retval = SUCCESS; - - zend_interned_strings_activate(); - -#if PHP_SIGCHLD - signal(SIGCHLD, sigchld_handler); -#endif - - if (php_start_sapi() == FAILURE) { - return FAILURE; - } - - php_output_activate(); - sapi_activate_headers_only(); - php_hash_environment(); - - return retval; -} /* }}} */ /* {{{ php_request_shutdown_for_exec @@ -1770,60 +1846,6 @@ void php_request_shutdown_for_exec(void *dummy) } /* }}} */ -/* {{{ php_request_shutdown_for_hook - */ -void php_request_shutdown_for_hook(void *dummy) -{ - - if (PG(modules_activated)) zend_try { - php_call_shutdown_functions(); - } zend_end_try(); - - if (PG(modules_activated)) { - zend_deactivate_modules(); - } - - if (PG(modules_activated)) { - php_free_shutdown_functions(); - } - - zend_try { - zend_unset_timeout(); - } zend_end_try(); - - zend_try { - int i; - - for (i = 0; i < NUM_TRACK_VARS; i++) { - zval_ptr_dtor(&PG(http_globals)[i]); - } - } zend_end_try(); - - zend_deactivate(); - - zend_try { - sapi_deactivate(); - } zend_end_try(); - - zend_try { - php_shutdown_stream_hashes(); - } zend_end_try(); - - zend_interned_strings_deactivate(); - - zend_try { - shutdown_memory_manager(CG(unclean_shutdown), 0); - } zend_end_try(); - -#ifdef ZEND_SIGNALS - zend_try { - zend_signal_deactivate(); - } zend_end_try(); -#endif -} - -/* }}} */ - /* {{{ php_request_shutdown */ void php_request_shutdown(void *dummy) @@ -2012,9 +2034,9 @@ PHP_MINFO_FUNCTION(php_core) { /* {{{ */ /* {{{ php_register_extensions */ -int php_register_extensions(zend_module_entry **ptr, int count) +int php_register_extensions(zend_module_entry * const * ptr, int count) { - zend_module_entry **end = ptr + count; + zend_module_entry * const * end = ptr + count; while (ptr < end) { if (*ptr) { @@ -2190,7 +2212,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod REGISTER_MAIN_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS_FAMILY", PHP_OS_FAMILY, sizeof(PHP_OS_FAMILY)-1, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS | CONST_NO_FILE_CACHE); REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PEAR_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS); @@ -2234,9 +2256,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod php_binary_init(); if (PG(php_binary)) { - REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", PG(php_binary), strlen(PG(php_binary)), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", PG(php_binary), strlen(PG(php_binary)), CONST_PERSISTENT | CONST_CS | CONST_NO_FILE_CACHE); } else { - REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", "", 0, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", "", 0, CONST_PERSISTENT | CONST_CS | CONST_NO_FILE_CACHE); } php_output_register_constants(); @@ -2274,6 +2296,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod CWDG(realpath_cache_size_limit) = 0; } + PG(have_called_openlog) = 0; + /* initialize stream wrappers registry * (this uses configuration parameters from php.ini) */ @@ -2332,7 +2356,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod module->info_func = PHP_MINFO(php_core); } - zend_post_startup(); + if (zend_post_startup() != SUCCESS) { + return FAILURE; + } module_initialized = 1; @@ -2407,7 +2433,11 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod shutdown_memory_manager(1, 0); virtual_cwd_activate(); - zend_interned_strings_switch_storage(); + zend_interned_strings_switch_storage(1); + +#if ZEND_RC_DEBUG + zend_rc_debug = 1; +#endif /* we're done */ return retval; @@ -2440,10 +2470,16 @@ void php_module_shutdown(void) return; } + zend_interned_strings_switch_storage(0); + #ifdef ZTS ts_free_worker_threads(); #endif +#if ZEND_RC_DEBUG + zend_rc_debug = 0; +#endif + #ifdef PHP_WIN32 (void)php_win32_shutdown_random_bytes(); #endif |
