retval = FAILURE; } zend_end_try(); return retval; }
# endif /* }}} */
/* {{{ php_request_startup_for_hook */
int php_request_startup_for_hook(TSRMLS_D) { int retval = SUCCESS; #if PHP_SIGCHLD signal(SIGCHLD, sigchld_handler); #endif if (php_start_sapi(TSRMLS_C) == FAILURE) { return FAILURE; } php_output_activate(TSRMLS_C); sapi_activate_headers_only(TSRMLS_C); php_hash_environment(TSRMLS_C); return retval; }
/* }}} */
/* {{{ php_request_shutdown_for_exec */
void php_request_shutdown_for_exec(void *dummy) { TSRMLS_FETCH(); /* used to close fd's in the 3..255 range here, but it's problematic */ shutdown_memory_manager(1, 1 TSRMLS_CC); }
/* }}} */
/* {{{ php_request_shutdown_for_hook */
void php_request_shutdown_for_hook(void *dummy) { TSRMLS_FETCH(); if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); php_free_shutdown_functions(TSRMLS_C); } zend_try { int i; for (i = 0; i < NUM_TRACK_VARS; i++) { if (PG(http_globals)[i]) { zval_ptr_dtor(&PG(http_globals)[i]); } } } zend_end_try(); zend_deactivate(TSRMLS_C);
zend_try { sapi_deactivate(TSRMLS_C); } zend_end_try(); zend_try { php_shutdown_stream_hashes(TSRMLS_C); } zend_end_try(); zend_try { shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC); } zend_end_try(); zend_try { zend_unset_timeout(TSRMLS_C); } zend_end_try(); }
/* }}} */
/* {{{ php_request_shutdown */
void php_request_shutdown(void *dummy) { zend_bool report_memleaks; TSRMLS_FETCH(); report_memleaks = PG(report_memleaks); /* EG(opline_ptr) points into nirvana and therefore cannot be safely accessed * inside zend_executor callback functions. */ EG(opline_ptr) = NULL; EG(active_op_array) = NULL; /* 1. Call all possible shutdown functions registered with register_shutdown_function() */ if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); /* 2. Call all possible __destruct() functions */ zend_try { zend_call_destructors(TSRMLS_C); } zend_end_try(); /* 3. Flush all output buffers */ zend_try { php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC); } zend_end_try(); /* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */ zend_try { sapi_send_headers(TSRMLS_C); } zend_end_try(); /* 5. Call all extensions RSHUTDOWN functions */ if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); php_free_shutdown_functions(TSRMLS_C); } /* 6. Destroy super-globals */ zend_try { int i; for (i=0; i } } zend_end_try(); /* 6.5 free last error information */ if (PG(last_error_message)) { free(PG(last_error_message)); PG(last_error_message) = NULL; } if (PG(last_error_file)) { free(PG(last_error_file)); PG(last_error_file) = NULL; } /* 7. Shutdown scanner/executor/compiler and restore ini entries */ zend_deactivate(TSRMLS_C); /* 8. Call all extensions post-RSHUTDOWN functions */ zend_try { zend_post_deactivate_modules(TSRMLS_C); } zend_end_try(); /* 9. SAPI related shutdown (free stuff) */ zend_try { sapi_deactivate(TSRMLS_C); } zend_end_try(); /* 10. Destroy stream hashes */ zend_try { php_shutdown_stream_hashes(TSRMLS_C); } zend_end_try(); /* 11. Free Willy (here be crashes) */ zend_try { shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0 TSRMLS_CC); } zend_end_try(); /* 12. Reset max_execution_time */ zend_try { zend_unset_timeout(TSRMLS_C); } zend_end_try(); #ifdef PHP_WIN32 if (PG(com_initialized)) { CoUninitialize(); PG(com_initialized) = 0; } #endif } /* }}} */ /* {{{ php_com_initialize */ PHPAPI void php_com_initialize(TSRMLS_D) { #ifdef PHP_WIN32 if (!PG(com_initialized)) { CoInitialize(NULL); PG(com_initialized) = 1; } #endif } /* }}} */ /* {{{ php_body_write_wrapper */ static int php_body_write_wrapper(const char *str, uint str_length) { TSRMLS_FETCH(); return php_body_write(str, str_length TSRMLS_CC); } /* }}} */ #ifdef ZTS /* {{{ core_globals_ctor */ static void core_globals_ctor(php_core_globals *core_globals TSRMLS_DC) { memset(core_globals, 0, sizeof(*core_globals)); } /* }}} */ #endif /* {{{ core_globals_dtor */ static void core_globals_dtor(php_core_globals *core_globals TSRMLS_DC) { if (core_globals->last_error_message) { free(core_globals->last_error_message); } if (core_globals->last_error_file) { free(core_globals->last_error_file); } if (core_globals->disable_functions) { free(core_globals->disable_functions); } if (core_globals->disable_classes) { free(core_globals->disable_classes); } } /* }}} */ /* {{{ php_register_extensions */ int php_register_extensions(zend_module_entry **ptr, int count TSRMLS_DC) { zend_module_entry **end = ptr + count; while (ptr < end) { if (*ptr) { if (zend_register_internal_module(*ptr TSRMLS_CC)==NULL) { return FAILURE; } } ptr++; } return SUCCESS; } /* }}} */ #if defined(PHP_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1400) static _invalid_parameter_handler old_invalid_parameter_handler; void dummy_invalid_parameter_handler( const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t pEwserved) { static int called = 0; char buf[1024]; int len; if (!called) { called = 1; if (function) { if (file) { len = _snprintf(buf, sizeof(buf)-1, \parameter detected in CRT function '%ws' (%ws:%d)\ } else { len = _snprintf(buf, sizeof(buf)-1, \parameter detected in CRT function '%ws'\function); } } else { len = _snprintf(buf, sizeof(buf)-1, \ } zend_error(E_WARNING, \ called = 0; } } #endif /* {{{ php_module_startup */ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules) { zend_utility_functions zuf; zend_utility_values zuv; int module_number=0; /* for REGISTER_INI_ENTRIES() */ char *php_os; #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)) WORD wVersionRequested = MAKEWORD(2, 0); WSADATA wsaData; #endif #ifdef PHP_WIN32 { DWORD dwVersion = GetVersion(); /* Get build numbers for Windows NT or Win95 */ if (dwVersion < 0x80000000){ php_os=\ } else { php_os=\ } }
相关推荐: