[PHP4BETA] CVS update: php4

From: Date: Fri, 23 Apr 1999 22:45:01 +0000
Subject: [PHP4BETA] CVS update: php4
Groups: php.version4 
Request: Send a blank email to php-version4+get-420@lists.php.net to get a copy of this message
Date: Friday April 23, 1999 @ 18:45 Author: zeev Update of /repository/php4 In directory php:/tmp/cvs-serv31345 Modified Files: main.c main.h php_globals.h Log Message: Remove redundant code Index: php4/main.c diff -u php4/main.c:1.27 php4/main.c:1.28 --- php4/main.c:1.27 Fri Apr 23 16:20:30 1999 +++ php4/main.c Fri Apr 23 18:45:00 1999 @@ -29,13 +29,9 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.27 1999/04/23 20:20:30 zeev Exp $ */ +/* $Id: main.c,v 1.28 1999/04/23 22:45:00 zeev Exp $ */ -#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 @@ -244,12 +240,14 @@ -#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; @@ -375,7 +373,7 @@ 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; } } @@ -629,8 +627,6 @@ 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 @@ -654,7 +650,6 @@ 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); @@ -697,29 +692,15 @@ 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); @@ -785,14 +766,7 @@ 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 } @@ -804,17 +778,17 @@ #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(); @@ -843,7 +817,6 @@ php3_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError()); return FAILURE; } - GLOBAL(module_initialized) |= INIT_WINSOCK; #endif SET_MUTEX(gLock); @@ -865,6 +838,7 @@ php3_printf("Unable to start modules\n"); return FAILURE; } + module_initialized = 1; return SUCCESS; } @@ -888,10 +862,7 @@ #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)) { @@ -908,6 +879,7 @@ UNREGISTER_INI_ENTRIES(); php_ini_mshutdown(); shutdown_memory_manager(0, 1); + module_initialized = 0; } @@ -1089,8 +1061,6 @@ /* need argc/argv support as well */ _php3_build_argv(GLOBAL(request_info).query_string ELS_CC); - GLOBAL(initialized) |= INIT_ENVIRONMENT; - return SUCCESS; } @@ -1466,10 +1436,6 @@ } 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) { @@ -1495,19 +1461,10 @@ 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 */ @@ -1534,13 +1491,10 @@ 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 */ @@ -1819,7 +1773,6 @@ } } GLOBAL(phpin) = in; - GLOBAL(initialized) |= INIT_SCANNER; phprestart(GLOBAL(phpin)); if (!processing_error) { @@ -1841,19 +1794,15 @@ } } - } - 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; } @@ -1950,7 +1899,6 @@ if (in) { GLOBAL(phpin) = in; phprestart(GLOBAL(phpin)); - GLOBAL(initialized) |= INIT_SCANNER; } if (sapi_info->display_source_mode) { GLOBAL(php3_display_source) = 1; Index: php4/main.h diff -u php4/main.h:1.3 php4/main.h:1.4 --- php4/main.h:1.3 Fri Apr 23 16:20:30 1999 +++ php4/main.h Fri Apr 23 18:45:00 1999 @@ -29,7 +29,7 @@ */ -/* $Id: main.h,v 1.3 1999/04/23 20:20:30 zeev Exp $ */ +/* $Id: main.h,v 1.4 1999/04/23 22:45:00 zeev Exp $ */ #ifndef _MAIN_H @@ -38,25 +38,12 @@ #include "zend_globals.h" #include "php_globals.h" -#define INIT_ENVIRONMENT 0x80 -#define INIT_REQUEST_INFO 0x400 -#define INIT_FUNCTIONS 0x800 -#define INIT_SCANNER 0x1000 -#define INIT_CONFIG 0x10000 -#define INIT_VARIABLE_UNASSIGN_STACK 0x20000 -#define INIT_WINSOCK 0x100000 -#define INIT_CLASS_TABLE 0x400000 - int php3_request_startup(CLS_D ELS_DC PLS_DC); extern void php3_request_shutdown(void *dummy INLINE_TLS); extern void php3_request_shutdown_for_exec(void *dummy); extern int php3_module_startup(); extern void php3_module_shutdown(); extern void php3_module_shutdown_for_exec(void); - -#ifndef THREAD_SAFE -extern int initialized; -#endif extern void php3_call_shutdown_functions(void); Index: php4/php_globals.h diff -u php4/php_globals.h:1.7 php4/php_globals.h:1.8 --- php4/php_globals.h:1.7 Fri Apr 23 16:20:30 1999 +++ php4/php_globals.h Fri Apr 23 18:45:00 1999 @@ -65,6 +65,7 @@ long y2k_compliance; unsigned char header_is_being_sent; + unsigned char initialized; }; -- PHP 4 Beta

« previous php.version4 (#420) next »