summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c81
1 files changed, 47 insertions, 34 deletions
diff --git a/main/main.c b/main/main.c
index 7deb3010d9..ee92bcc7b4 100644
--- a/main/main.c
+++ b/main/main.c
@@ -34,11 +34,6 @@
#include "win32/php_win32_globals.h"
#include "win32/winutil.h"
#include <process.h>
-#elif defined(NETWARE)
-#include <sys/timeval.h>
-#ifdef USE_WINSOCK
-#include <novsock2.h>
-#endif
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
@@ -536,8 +531,8 @@ PHP_INI_MH(OnChangeBrowscap);
* PHP_INCLUDE_PATH
*/
- /* Windows and Netware use the internal mail */
-#if defined(PHP_WIN32) || defined(NETWARE)
+ /* Windows use the internal mail */
+#if defined(PHP_WIN32)
# define DEFAULT_SENDMAIL_PATH NULL
#elif defined(PHP_PROG_SENDMAIL)
# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i "
@@ -577,7 +572,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
- STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, sql_safe_mode, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals)
@@ -939,7 +933,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
efree(docref_buf);
}
- if (PG(track_errors) && module_initialized && EG(valid_symbol_table) &&
+ if (PG(track_errors) && module_initialized && EG(active) &&
(Z_TYPE(EG(user_error_handler)) == IS_UNDEF || !(EG(user_error_handler_error_reporting) & type))) {
zval tmp;
ZVAL_STRINGL(&tmp, buffer, buffer_len);
@@ -1035,7 +1029,7 @@ PHPAPI void php_html_puts(const char *str, size_t size)
/* {{{ php_error_cb
extended error handling function */
-static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
+static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
{
char *buffer;
int buffer_len, display;
@@ -1264,7 +1258,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
return;
}
- if (PG(track_errors) && module_initialized && EG(valid_symbol_table)) {
+ if (PG(track_errors) && module_initialized && EG(active)) {
zval tmp;
ZVAL_STRINGL(&tmp, buffer, buffer_len);
@@ -1630,6 +1624,8 @@ int php_request_startup(void)
{
int retval = SUCCESS;
+ zend_interned_strings_activate();
+
#ifdef HAVE_DTRACE
DTRACE_REQUEST_STARTUP(SAFE_FILENAME(SG(request_info).path_translated), SAFE_FILENAME(SG(request_info).request_uri), (char *)SAFE_FILENAME(SG(request_info).request_method));
#endif /* HAVE_DTRACE */
@@ -1710,6 +1706,8 @@ int php_request_startup(void)
{
int retval = SUCCESS;
+ zend_interned_strings_activate();
+
#if PHP_SIGCHILD
signal(SIGCHLD, sigchld_handler);
#endif
@@ -1742,6 +1740,8 @@ int php_request_startup_for_hook(void)
{
int retval = SUCCESS;
+ zend_interned_strings_activate();
+
#if PHP_SIGCHLD
signal(SIGCHLD, sigchld_handler);
#endif
@@ -1765,8 +1765,8 @@ void php_request_shutdown_for_exec(void *dummy)
/* used to close fd's in the 3..255 range here, but it's problematic
*/
+ zend_interned_strings_deactivate();
shutdown_memory_manager(1, 1);
- zend_interned_strings_restore();
}
/* }}} */
@@ -1809,12 +1809,12 @@ void php_request_shutdown_for_hook(void *dummy)
php_shutdown_stream_hashes();
} zend_end_try();
+ zend_interned_strings_deactivate();
+
zend_try {
shutdown_memory_manager(CG(unclean_shutdown), 0);
} zend_end_try();
- zend_interned_strings_restore();
-
#ifdef ZEND_SIGNALS
zend_try {
zend_signal_deactivate();
@@ -1830,6 +1830,8 @@ void php_request_shutdown(void *dummy)
{
zend_bool report_memleaks;
+ EG(flags) |= EG_FLAGS_IN_SHUTDOWN;
+
report_memleaks = PG(report_memleaks);
/* EG(current_execute_data) points into nirvana and therefore cannot be safely accessed
@@ -1920,7 +1922,7 @@ void php_request_shutdown(void *dummy)
} zend_end_try();
/* 15. Free Willy (here be crashes) */
- zend_interned_strings_restore();
+ zend_interned_strings_deactivate();
zend_try {
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
} zend_end_try();
@@ -1971,6 +1973,7 @@ 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
@@ -2077,7 +2080,7 @@ void dummy_invalid_parameter_handler(
/* {{{ php_module_startup
*/
-int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules)
+int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint32_t num_additional_modules)
{
zend_utility_functions zuf;
zend_utility_values zuv;
@@ -2085,11 +2088,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
char *php_os;
zend_module_entry *module;
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
+#ifdef PHP_WIN32
WORD wVersionRequested = MAKEWORD(2, 0);
WSADATA wsaData;
-#endif
-#ifdef PHP_WIN32
+
php_os = "WINNT";
old_invalid_parameter_handler =
@@ -2109,7 +2111,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
#endif
#ifdef PHP_WIN32
- php_win32_init_rng_lock();
+ if (!php_win32_init_random_bytes()) {
+ fprintf(stderr, "\ncrypt algorithm provider initialization failed\n");
+ return FAILURE;
+ }
#endif
module_shutdown = 0;
@@ -2127,7 +2132,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
#ifdef ZTS
ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
- 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
@@ -2146,8 +2150,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
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.printf_to_smart_string_function = php_printf_to_smart_string;
+ zuf.printf_to_smart_str_function = php_printf_to_smart_str;
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
zend_startup(&zuf, NULL);
@@ -2161,7 +2165,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
tzset();
#endif
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
+#ifdef PHP_WIN32
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
@@ -2185,6 +2189,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
#endif
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("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);
@@ -2208,6 +2213,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", ZEND_LONG_MIN, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_LONG, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_FD_SETSIZE", FD_SETSIZE, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_FLOAT_DIG", DBL_DIG, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_EPSILON", DBL_EPSILON, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_MAX", DBL_MAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_MIN", DBL_MIN, CONST_PERSISTENT | CONST_CS);
#ifdef PHP_WIN32
REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS);
@@ -2275,7 +2284,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuv.html_errors = 1;
zuv.import_use_extension = ".php";
- zuv.import_use_extension_length = (uint)strlen(zuv.import_use_extension);
+ zuv.import_use_extension_length = (uint32_t)strlen(zuv.import_use_extension);
php_startup_auto_globals();
zend_set_utility_values(&zuv);
php_startup_sapi_content_types();
@@ -2337,8 +2346,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
} directives[2] = {
{
E_DEPRECATED,
- "Directive '%s' is deprecated in PHP 5.3 and greater",
+ "Directive '%s' is deprecated",
{
+ "track_errors",
NULL
}
},
@@ -2389,13 +2399,16 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
} zend_end_try();
}
+ virtual_cwd_deactivate();
+
sapi_deactivate();
module_startup = 0;
shutdown_memory_manager(1, 0);
- zend_interned_strings_snapshot();
virtual_cwd_activate();
+ zend_interned_strings_switch_storage();
+
/* we're done */
return retval;
}
@@ -2431,19 +2444,19 @@ void php_module_shutdown(void)
ts_free_worker_threads();
#endif
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
- /*close winsock */
- WSACleanup();
-#endif
-
#ifdef PHP_WIN32
- php_win32_free_rng_lock();
+ (void)php_win32_shutdown_random_bytes();
#endif
sapi_flush();
zend_shutdown();
+#ifdef PHP_WIN32
+ /*close winsock */
+ WSACleanup();
+#endif
+
/* Destroys filter & transport registries too */
php_shutdown_stream_wrappers(module_number);
@@ -2524,7 +2537,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
* otherwise it will get opened and added to the included_files list in zend_execute_scripts
*/
if (primary_file->filename &&
- (primary_file->filename[0] != '-' || primary_file->filename[1] != 0) &&
+ strcmp("Standard input code", primary_file->filename) &&
primary_file->opened_path == NULL &&
primary_file->type != ZEND_HANDLE_FILENAME
) {