/* $Id$ */
-#define SHUTDOWN_DEBUG(resource) fprintf(stderr, "*** Shutting down " resource "\n" )
-#undef SHUTDOWN_DEBUG
-#define SHUTDOWN_DEBUG(resource)
-
#include <stdio.h>
#include "php.h"
#ifdef MSVC5
-#ifndef THREAD_SAFE
+/* True global (no need for thread safety */
+static int module_initialized = 0;
+
+#ifndef ZTS
+
/*
* Globals yet to be protected
*/
-int initialized; /* keep track of which resources were successfully initialized */
-static int module_initialized = 0;
#if WIN32|WINNT
unsigned int wintimer;
PLS_FETCH();
if (!(type & E_CORE)) {
- if (!GLOBAL(initialized)) { /* don't display further errors after php3_request_shutdown() */
+ if (!PG(initialized)) { /* don't display further errors after php3_request_shutdown() */
return;
}
}
php3_set_timeout(PG(max_execution_time) _INLINE_TLS);
- GLOBAL(initialized) = 0;
-
#if APACHE
/*
* For the Apache module version, this bit of code registers a cleanup
php3_printf("Unable to initialize request info.\n");
return FAILURE;
}
- GLOBAL(initialized) |= INIT_REQUEST_INFO;
init_compiler(CLS_C ELS_CC);
init_executor(CLS_C ELS_CC);
php3_call_shutdown_functions();
- GLOBAL(initialized) &= ~INIT_ENVIRONMENT; /* does not require any special shutdown */
-
php_ini_rshutdown();
shutdown_scanner(CLS_C);
-
shutdown_compiler(CLS_C);
shutdown_executor(ELS_C);
- if (GLOBAL(initialized) & INIT_REQUEST_INFO) {
- SHUTDOWN_DEBUG("Request info");
- php3_destroy_request_info(NULL);
- GLOBAL(initialized) &= ~INIT_REQUEST_INFO;
- }
- if (GLOBAL(initialized) & INIT_SCANNER) {
- SHUTDOWN_DEBUG("Scanner");
- GLOBAL(initialized) &= ~INIT_SCANNER;
- }
- SHUTDOWN_DEBUG("Memory manager");
+ php3_destroy_request_info(NULL);
shutdown_memory_manager(0, 0);
- if (GLOBAL(initialized)) {
- php3_error(E_WARNING, "Unknown resources in request shutdown function");
- }
+ php3_error(E_WARNING, "Unknown resources in request shutdown function");
php3_unset_timeout(_INLINE_TLS_VOID);
static void php3_config_ini_shutdown(INLINE_TLS_VOID)
{
-#if USE_SAPI
php3_shutdown_config();
-#else
- if (GLOBAL(module_initialized) & INIT_CONFIG) {
- php3_shutdown_config();
- GLOBAL(module_initialized) &= ~INIT_CONFIG;
- }
-#endif
}
#ifdef ZTS
php_core_globals *core_globals;
#endif
-
#if (WIN32|WINNT) && !(USE_SAPI)
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(2, 0);
-#else
- if (GLOBAL(module_initialized)) {
+#endif
+
+
+ if (module_initialized) {
return SUCCESS;
}
-#endif
zend_output_startup();
php3_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
return FAILURE;
}
- GLOBAL(module_initialized) |= INIT_WINSOCK;
#endif
SET_MUTEX(gLock);
php3_printf("Unable to start modules\n");
return FAILURE;
}
+ module_initialized = 1;
return SUCCESS;
}
#if (WIN32|WINNT) && !(USE_SAPI)
/*close winsock */
- if (GLOBAL(module_initialized) & INIT_WINSOCK) {
- WSACleanup();
- GLOBAL(module_initialized) &= ~INIT_WINSOCK;
- }
+ WSACleanup();
#endif
if (GLOBAL(module_initialized)) {
UNREGISTER_INI_ENTRIES();
php_ini_mshutdown();
shutdown_memory_manager(0, 1);
+ module_initialized = 0;
}
/* need argc/argv support as well */
_php3_build_argv(GLOBAL(request_info).query_string ELS_CC);
- GLOBAL(initialized) |= INIT_ENVIRONMENT;
-
return SUCCESS;
}
} else {
rewind(file_handle.handle.fp);
}
- GLOBAL(initialized) |= INIT_SCANNER;
- /* This shouldn't be necessary - if it is - it should move to Zend
- * phprestart(GLOBAL(phpin));
- */
}
switch (behavior) {
break;
}
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- php3_module_shutdown(_INLINE_TLS_VOID);
-#ifdef THREAD_SAFE
- yy_destroy_tls();
- tls_shutdown();
- tls_destroy();
-#endif
- return SUCCESS;
- } else {
- return FAILURE;
- }
+ php3_header(); /* Make sure headers have been sent */
+ php3_request_shutdown((void *) 0 _INLINE_TLS);
+ php3_module_shutdown(_INLINE_TLS_VOID);
+ return SUCCESS;
}
#endif /* CGI_BINARY */
file_handle.type = ZEND_HANDLE_FD;
file_handle.handle.fd = fd;
file_handle.filename = request_info.filename;
- GLOBAL(initialized) |= INIT_SCANNER;
(void) php3_parse(&file_handle CLS_CC ELS_CC);
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- zend_end_ob_buffering(1);
- }
+ php3_header(); /* Make sure headers have been sent */
+ zend_end_ob_buffering(1);
return (OK);
}
#endif /* APACHE */
}
}
GLOBAL(phpin) = in;
- GLOBAL(initialized) |= INIT_SCANNER;
phprestart(GLOBAL(phpin));
if (!processing_error) {
}
}
}
- if (GLOBAL(initialized)) {
- php3_header(); /* Make sure headers have been sent */
- php3_request_shutdown((void *) 0 _INLINE_TLS);
- }
+ php3_header(); /* Make sure headers have been sent */
+ php3_request_shutdown((void *) 0 _INLINE_TLS);
}
php3_module_shutdown(_INLINE_TLS_VOID);
#ifdef THREAD_SAFE
- if (GLOBAL(initialized)) {
- yy_destroy_tls();
- tls_shutdown();
- tls_destroy();
- }
+ yy_destroy_tls();
+ tls_shutdown();
+ tls_destroy();
#endif
return 0;
}
if (in) {
GLOBAL(phpin) = in;
phprestart(GLOBAL(phpin));
- GLOBAL(initialized) |= INIT_SCANNER;
}
if (sapi_info->display_source_mode) {
GLOBAL(php3_display_source) = 1;