CVS update: php31/main

From: Date: Tue, 22 Sep 1998 14:25:36 +0000
Subject: CVS update: php31/main
Groups: php.dev 
Request: Send a blank email to php-dev+get-1380@lists.php.net to get a copy of this message
Date: Tuesday September 22, 1998 @ 10:25 Author: zeev Update of /repository/php31/main In directory asf:/u2/tmp/cvs-serv12570/main Modified Files: alloc.c alloc.h main.c main.h Log Message: Cross request cache to the memory manager. Untested, need the Apache module for this. Also, Shane, I have *no* idea what's going on in main.c, start_memory_manager() should be called exactly once for each process, or thread, before just about anything else. Index: php31/main/alloc.c diff -c php31/main/alloc.c:2.4 php31/main/alloc.c:2.5 *** php31/main/alloc.c:2.4 Thu Sep 3 14:41:54 1998 --- php31/main/alloc.c Tue Sep 22 10:25:34 1998 *************** *** 108,114 **** TLS_VARS; #if DEBUG ! if (!(GLOBAL(initialized) & INIT_MEMORY_MANAGER)) { fprintf(stderr,"WARNING: Call to emalloc() before memory manager is started from %s:%d (%d bytes)\n",filename,lineno,size); } #endif --- 108,114 ---- TLS_VARS; #if DEBUG ! if (!(GLOBAL(module_initialized) & INIT_MEMORY_MANAGER)) { fprintf(stderr,"WARNING: Call to emalloc() before memory manager is started from %s:%d (%d bytes)\n",filename,lineno,size); } #endif *************** *** 121,126 **** --- 121,127 ---- p->filename = strdup(filename); p->lineno = lineno; #endif + p->size *= -1; UNBLOCK_INTERRUPTIONS; return (void *)((char *)p + sizeof(mem_header) + PLATFORM_PADDING); } else { *************** *** 161,168 **** if ((p->size < MAX_CACHED_MEMORY) && (GLOBAL(cache_count[p->size]) < MAX_CACHED_ENTRIES)) { GLOBAL(cache[p->size][GLOBAL(cache_count[p->size]++)]) = p; #if DEBUG ! free(p->filename); p->filename = NULL; #endif return; --- 162,172 ---- if ((p->size < MAX_CACHED_MEMORY) && (GLOBAL(cache_count[p->size]) < MAX_CACHED_ENTRIES)) { GLOBAL(cache[p->size][GLOBAL(cache_count[p->size]++)]) = p; + p->size *= -1; #if DEBUG ! if (p->filename) { ! free(p->filename); ! } p->filename = NULL; #endif return; *************** *** 330,379 **** #endif memset(GLOBAL(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned char)); ! GLOBAL(initialized) |= INIT_MEMORY_MANAGER; } ! void shutdown_memory_manager(void) { mem_header *p, *t; - unsigned int i,j; TLS_VARS; ! ! BLOCK_INTERRUPTIONS; ! for (i=0; i<MAX_CACHED_MEMORY; i++) { ! for (j=0; j<GLOBAL(cache_count[i]); j++) { ! p = GLOBAL(cache[i][j]); ! REMOVE_POINTER_FROM_LIST(p); ! #if DEBUG ! if (p->filename) { ! free(p->filename); ! } ! #endif ! free(p); ! } ! } ! UNBLOCK_INTERRUPTIONS; ! p=GLOBAL(head); t=GLOBAL(head); while (t) { #if DEBUG /* does not use php3_error() *intentionally* */ ! if (GLOBAL(error_reporting) & E_WARNING && GLOBAL(shutdown_requested)!=ABNORMAL_SHUTDOWN) { # if CRASH_DETECTION /* log into the errorlog, since at this time we can't send messages to the browser */ debug_log("Possible PHP3 memory leak detected (harmless): %d bytes from %s:%d\n",t->size,t->filename,t->lineno); # endif } #endif p = t->pNext; #if DEBUG ! free(t->filename); #endif ! free(t); ! t = p; } GLOBAL(initialized) &= ~INIT_MEMORY_MANAGER; } void memory_manager_status(unsigned char verbose) { --- 334,391 ---- #endif memset(GLOBAL(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned char)); ! GLOBAL(module_initialized) |= INIT_MEMORY_MANAGER; } + ! void memory_manager_rshutdown(void) { mem_header *p, *t; TLS_VARS; ! ! /* clear all the memory that has leaked, except for the cached blocks */ p=GLOBAL(head); t=GLOBAL(head); while (t) { #if DEBUG /* does not use php3_error() *intentionally* */ ! if (t->size>0 && GLOBAL(error_reporting) & E_WARNING && GLOBAL(shutdown_requested)!=ABNORMAL_SHUTDOWN) { # if CRASH_DETECTION /* log into the errorlog, since at this time we can't send messages to the browser */ debug_log("Possible PHP3 memory leak detected (harmless): %d bytes from %s:%d\n",t->size,t->filename,t->lineno); # endif } #endif p = t->pNext; + efree(((char *) t)+sizeof(mem_header)+PLATFORM_PADDING); + t = p; + } + } + + + void memory_manager_mshutdown(void) + { + unsigned int i, j; + mem_header *p; + + memory_manager_rshutdown(); + + BLOCK_INTERRUPTIONS; + for (i=0; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<GLOBAL(cache_count[i]); j++) { + p = GLOBAL(cache[i][j]); + REMOVE_POINTER_FROM_LIST(p); #if DEBUG ! if (p->filename) { ! free(p->filename); ! } #endif ! free(p); ! } } + UNBLOCK_INTERRUPTIONS; GLOBAL(initialized) &= ~INIT_MEMORY_MANAGER; } + void memory_manager_status(unsigned char verbose) { Index: php31/main/alloc.h diff -c php31/main/alloc.h:2.1 php31/main/alloc.h:2.2 *** php31/main/alloc.h:2.1 Thu Aug 20 20:15:28 1998 --- php31/main/alloc.h Tue Sep 22 10:25:34 1998 *************** *** 93,99 **** #define safe_estrndup(ptr,len) ((ptr)?(estrndup((ptr),(len))):(empty_string)) extern void start_memory_manager(void); ! extern void shutdown_memory_manager(void); extern void memory_manager_status(unsigned char verbose); #endif --- 93,100 ---- #define safe_estrndup(ptr,len) ((ptr)?(estrndup((ptr),(len))):(empty_string)) extern void start_memory_manager(void); ! extern void memory_manager_rshutdown(void); ! extern void memory_manager_mshutdown(void); extern void memory_manager_status(unsigned char verbose); #endif Index: php31/main/main.c diff -c php31/main/main.c:2.38 php31/main/main.c:2.39 *** php31/main/main.c:2.38 Sat Sep 19 08:16:37 1998 --- php31/main/main.c Tue Sep 22 10:25:35 1998 *************** *** 29,35 **** +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.38 1998/09/19 12:16:37 zeev Exp $ */ /* #define CRASH_DETECTION */ --- 29,35 ---- +----------------------------------------------------------------------+ */ ! /* $Id: main.c,v 2.39 1998/09/22 14:25:35 zeev Exp $ */ /* #define CRASH_DETECTION */ *************** *** 93,99 **** MUTEX_T gLock; #else struct sapi_request_info *sapi_rqst; ! #endif /* THREAD_SAFE */ #if MSVC5 || !defined(HAVE_GETOPT) #include "sapi/getopt.h" --- 93,99 ---- MUTEX_T gLock; #else struct sapi_request_info *sapi_rqst; ! #endif /* THREAD_SAFE */ #if MSVC5 || !defined(HAVE_GETOPT) #include "sapi/getopt.h" *************** *** 106,133 **** int error_reporting, tmp_error_reporting; int initialized; /* keep track of which resources were successfully initialized */ ! static int module_initialized = 0; int shutdown_requested; unsigned char header_is_being_sent; unsigned int max_execution_time = 0; HashTable configuration_hash; extern FILE *phpin; php3_ini_structure *php3_ini; ! unsigned int client_alive=1; ! # if PHP_DEBUGGER extern int debugger_on; ! # endif ! # if WIN32|WINNT unsigned int wintimer; unsigned int timerstart; unsigned int wintimer_counter = 0; ! # endif ! #endif /* not THREAD_SAFE */ #define AC_INIT_TABLE #include "automated_configuration.h" --- 106,133 ---- int error_reporting, tmp_error_reporting; int initialized; /* keep track of which resources were successfully initialized */ ! int module_initialized = 0; int shutdown_requested; unsigned char header_is_being_sent; unsigned int max_execution_time = 0; HashTable configuration_hash; extern FILE *phpin; php3_ini_structure *php3_ini; ! unsigned int client_alive = 1; ! #if PHP_DEBUGGER extern int debugger_on; ! #endif ! #if WIN32|WINNT unsigned int wintimer; unsigned int timerstart; unsigned int wintimer_counter = 0; ! #endif ! #endif /* not THREAD_SAFE */ #define AC_INIT_TABLE #include "automated_configuration.h" *************** *** 150,162 **** char buffer[1024]; #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex,php3_globals); #endif va_start(args, format); vsprintf(buffer, format, args); #if 0 ! if(php3_globals && GLOBAL(sapi_rqst)){ /* be sure we realy are started up first!*/ GLOBAL(sapi_rqst)->debug_log(SAPI_GLOBAL_PASS buffer); } #endif --- 150,162 ---- char buffer[1024]; #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex, php3_globals); #endif va_start(args, format); vsprintf(buffer, format, args); #if 0 ! if (php3_globals && GLOBAL(sapi_rqst)) { /* be sure we realy are started up first! */ GLOBAL(sapi_rqst)->debug_log(SAPI_GLOBAL_PASS buffer); } #endif *************** *** 164,170 **** #if MSVC5 OutputDebugString(buffer); #else ! fprintf(stderr,buffer); #endif va_end(args); --- 164,170 ---- #if MSVC5 OutputDebugString(buffer); #else ! fprintf(stderr, buffer); #endif va_end(args); *************** *** 240,246 **** PHPAPI int php3_write(void *buf, int size) { TLS_VARS; ! return php3_sapi_writeclient(buf, size _INLINE_TLS); } --- 240,246 ---- PHPAPI int php3_write(void *buf, int size) { TLS_VARS; ! return php3_sapi_writeclient(buf, size _INLINE_TLS); } *************** *** 250,260 **** if (GLOBAL(sapi_rqst)->buffered_output) { string_buffer_concat(&GLOBAL(sapi_rqst)->output_buffer, buf, size); return size; ! } else if(GLOBAL(client_alive)){ ! if((ret=GLOBAL(sapi_rqst)->writeclient(SAPI_GLOBAL_PASS buf,size))<size) ! GLOBAL(client_alive)=0; else ! GLOBAL(client_alive)=1; return ret; } return 0; --- 250,260 ---- if (GLOBAL(sapi_rqst)->buffered_output) { string_buffer_concat(&GLOBAL(sapi_rqst)->output_buffer, buf, size); return size; ! } else if (GLOBAL(client_alive)) { ! if ((ret = GLOBAL(sapi_rqst)->writeclient(SAPI_GLOBAL_PASS buf, size)) < size) ! GLOBAL(client_alive) = 0; else ! GLOBAL(client_alive) = 1; return ret; } return 0; *************** *** 274,292 **** va_start(args, format); size = vsprintf(buffer, format, args); ! /* fix for memory manager shutting down before request is started! */ #if DEBUG ! if(GLOBAL(sapi_rqst)) { ! ret=php3_sapi_writeclient(buffer, size _INLINE_TLS); } else { ! # if defined(CRASH_DETECTION) debug_log(buffer); ! # endif ! ret=0; } ! #else /* DEBUG=0 */ ! ret=php3_sapi_writeclient(buffer, size _INLINE_TLS); #endif va_end(args); --- 274,292 ---- va_start(args, format); size = vsprintf(buffer, format, args); ! /* fix for memory manager shutting down before request is started! */ #if DEBUG ! if (GLOBAL(sapi_rqst)) { ! ret = php3_sapi_writeclient(buffer, size _INLINE_TLS); } else { ! #if defined(CRASH_DETECTION) debug_log(buffer); ! #endif ! ret = 0; } ! #else /* DEBUG=0 */ ! ret = php3_sapi_writeclient(buffer, size _INLINE_TLS); #endif va_end(args); *************** *** 351,357 **** if (!php3_header()) { return; } - php3_printf("<br>\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br>\n", error_type_str, buffer, filename, GLOBAL(current_lineno) % MAX_TOKENS_PER_CACHE); } } --- 351,356 ---- *************** *** 410,429 **** #endif if (!GLOBAL(initialized) || GLOBAL(shutdown_requested)) { ! if (GLOBAL(shutdown_requested)==TERMINATE_CURRENT_PHPPARSE) { ! GLOBAL(shutdown_requested)=0; ! } return 0; } - /* FIXME? Do we realy want to abort the script if the client is ! no longer alive? That could reek havoc in someone's script. ! for now, letting the script finish. ! if (!GLOBAL(client_alive)) { ! GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN; ! return 0; ! } ! */ #ifdef THREAD_SAFE switch (read_next_token(&GLOBAL(token_cache_manager), &token, phplval, php3_globals, php_flex_gbl)) { --- 409,427 ---- #endif if (!GLOBAL(initialized) || GLOBAL(shutdown_requested)) { ! if (GLOBAL(shutdown_requested) == TERMINATE_CURRENT_PHPPARSE) { ! GLOBAL(shutdown_requested) = 0; ! } return 0; } /* FIXME? Do we realy want to abort the script if the client is ! no longer alive? That could reek havoc in someone's script. ! for now, letting the script finish. ! if (!GLOBAL(client_alive)) { ! GLOBAL(shutdown_requested) = ABNORMAL_SHUTDOWN; ! return 0; ! } ! */ #ifdef THREAD_SAFE switch (read_next_token(&GLOBAL(token_cache_manager), &token, phplval, php3_globals, php_flex_gbl)) { *************** *** 520,541 **** int php3_request_startup(INLINE_TLS_VOID) { ! /* ! * Copy the master php3_ini struct into the request copy ! */ /* for now we'll simply copy the master ini into the request ini later, well come up with some idea for a per directory ini file. ! Probably have to add a sapi callback to the server module. We ! could set a ini variable to tell us wether or not to make that ! call. Will need to do this before apache directives will ! work again. ! ! Note this is called before request startup, so we dont use ! emalloc. We have to free this at the end of this request. ! */ ! GLOBAL(php3_ini)=_php3_copy_ini_master(); #if defined(CRASH_DETECTION) debug_log("php3_request_startup()"); #endif --- 518,539 ---- int php3_request_startup(INLINE_TLS_VOID) { ! /* ! * Copy the master php3_ini struct into the request copy ! */ /* for now we'll simply copy the master ini into the request ini later, well come up with some idea for a per directory ini file. ! Probably have to add a sapi callback to the server module. We ! could set a ini variable to tell us wether or not to make that ! call. Will need to do this before apache directives will ! work again. + Note this is called before request startup, so we dont use + emalloc. We have to free this at the end of this request. + */ + GLOBAL(php3_ini) = _php3_copy_ini_master(); + #if defined(CRASH_DETECTION) debug_log("php3_request_startup()"); #endif *************** *** 544,553 **** php3_set_timeout(GLOBAL(max_execution_time) _INLINE_TLS); GLOBAL(initialized) = 0; - - start_memory_manager(); ! /*get the server config from the registry, if we are using that*/ #if WIN32|WINNT if (php3_ini_master.use_registry) { _reg_get_server_config(GLOBAL(sapi_rqst)->server_name _INLINE_TLS); --- 542,549 ---- php3_set_timeout(GLOBAL(max_execution_time) _INLINE_TLS); GLOBAL(initialized) = 0; ! /*get the server config from the registry, if we are using that */ #if WIN32|WINNT if (php3_ini_master.use_registry) { _reg_get_server_config(GLOBAL(sapi_rqst)->server_name _INLINE_TLS); *************** *** 588,594 **** GLOBAL(phplineno) = 1; GLOBAL(error_reporting) = GLOBAL(php3_ini)->error_reporting; GLOBAL(shutdown_requested) = 0; ! GLOBAL(header_is_being_sent) = 0; GLOBAL(php3_track_vars) = GLOBAL(php3_ini)->track_vars; GLOBAL(error_reporting) = GLOBAL(php3_ini)->error_reporting; --- 584,590 ---- GLOBAL(phplineno) = 1; GLOBAL(error_reporting) = GLOBAL(php3_ini)->error_reporting; GLOBAL(shutdown_requested) = 0; ! GLOBAL(header_is_being_sent) = 0; GLOBAL(php3_track_vars) = GLOBAL(php3_ini)->track_vars; GLOBAL(error_reporting) = GLOBAL(php3_ini)->error_reporting; *************** *** 681,689 **** void php3_request_shutdown_for_exec(void *dummy) { TLS_VARS; ! GLOBAL(error_reporting) = 0; ! shutdown_memory_manager(); } --- 677,685 ---- void php3_request_shutdown_for_exec(void *dummy) { TLS_VARS; ! GLOBAL(error_reporting) = 0; ! memory_manager_mshutdown(); } *************** *** 692,698 **** #if defined(CRASH_DETECTION) debug_log("php3_request_shutdown()\n"); #endif ! if (GLOBAL(initialized) & INIT_SYMBOL_TABLE) { _php3_hash_destroy(&GLOBAL(symbol_table)); GLOBAL(initialized) &= ~INIT_SYMBOL_TABLE; --- 688,694 ---- #if defined(CRASH_DETECTION) debug_log("php3_request_shutdown()\n"); #endif ! if (GLOBAL(initialized) & INIT_SYMBOL_TABLE) { _php3_hash_destroy(&GLOBAL(symbol_table)); GLOBAL(initialized) &= ~INIT_SYMBOL_TABLE; *************** *** 700,734 **** GLOBAL(initialized) &= ~INIT_ENVIRONMENT; /* does not require any special shutdown */ #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SYMBOL_TABLE\n",GetCurrentThreadId()); #endif /* remove classes and user-functions */ if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) { _php3_hash_apply(&GLOBAL(function_table), (int (*)(void *)) is_not_internal_function); } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FUNCTION_TABLE\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_TOKEN_CACHE) { tcm_destroy(&GLOBAL(token_cache_manager)); GLOBAL(initialized) &= ~INIT_TOKEN_CACHE; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_TOKEN_CACHE\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_CSS) { stack_destroy(&GLOBAL(css)); GLOBAL(initialized) &= ~INIT_CSS; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_CSS\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_FOR_STACK) { stack_destroy(&GLOBAL(for_stack)); GLOBAL(initialized) &= ~INIT_FOR_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FOR_STACK\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_SWITCH_STACK) { switch_expr *se; --- 696,730 ---- GLOBAL(initialized) &= ~INIT_ENVIRONMENT; /* does not require any special shutdown */ #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SYMBOL_TABLE\n", GetCurrentThreadId()); #endif /* remove classes and user-functions */ if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) { _php3_hash_apply(&GLOBAL(function_table), (int (*)(void *)) is_not_internal_function); } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FUNCTION_TABLE\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_TOKEN_CACHE) { tcm_destroy(&GLOBAL(token_cache_manager)); GLOBAL(initialized) &= ~INIT_TOKEN_CACHE; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_TOKEN_CACHE\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_CSS) { stack_destroy(&GLOBAL(css)); GLOBAL(initialized) &= ~INIT_CSS; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_CSS\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_FOR_STACK) { stack_destroy(&GLOBAL(for_stack)); GLOBAL(initialized) &= ~INIT_FOR_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FOR_STACK\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_SWITCH_STACK) { switch_expr *se; *************** *** 741,747 **** GLOBAL(initialized) &= ~INIT_SWITCH_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SWITCH_STACK\n",GetCurrentThreadId()); #endif --- 737,743 ---- GLOBAL(initialized) &= ~INIT_SWITCH_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SWITCH_STACK\n", GetCurrentThreadId()); #endif *************** *** 752,770 **** #if 0 && defined(CRASH_DETECTION) debug_log("%d:INIT_PHPCHAR_STACK\n", GetCurrentThreadId()); #endif ! if (GLOBAL(initialized) & INIT_INCLUDE_STACK) { clean_input_source_stack(); GLOBAL(initialized) &= ~INIT_INCLUDE_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_INCLUDE_STACK\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_FUNCTION_STATE_STACK) { FunctionState *tmp; ! HashTable *last_symbol_table=NULL; /* to protect against freeing the same symtable twice, ! * if we 'crashed' in a nested function call ! */ while (stack_top(&GLOBAL(function_state_stack), (void **) &tmp) != FAILURE) { if (tmp->function_name) { --- 748,766 ---- #if 0 && defined(CRASH_DETECTION) debug_log("%d:INIT_PHPCHAR_STACK\n", GetCurrentThreadId()); #endif ! if (GLOBAL(initialized) & INIT_INCLUDE_STACK) { clean_input_source_stack(); GLOBAL(initialized) &= ~INIT_INCLUDE_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_INCLUDE_STACK\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_FUNCTION_STATE_STACK) { FunctionState *tmp; ! HashTable *last_symbol_table = NULL; /* to protect against freeing the same symtable twice, ! * if we 'crashed' in a nested function call ! */ while (stack_top(&GLOBAL(function_state_stack), (void **) &tmp) != FAILURE) { if (tmp->function_name) { *************** *** 792,798 **** GLOBAL(initialized) &= ~INIT_FUNCTION_STATE_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FUNCTION_STATE_STACK\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_VARIABLE_UNASSIGN_STACK) { variable_tracker *tmp; --- 788,794 ---- GLOBAL(initialized) &= ~INIT_FUNCTION_STATE_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_FUNCTION_STATE_STACK\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_VARIABLE_UNASSIGN_STACK) { variable_tracker *tmp; *************** *** 806,867 **** stack_destroy(&GLOBAL(variable_unassign_stack)); GLOBAL(initialized) &= ~INIT_VARIABLE_UNASSIGN_STACK; } - #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_VARIABLE_UNASSIGN_STACK\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_LIST) { destroy_resource_list(); GLOBAL(initialized) &= ~INIT_LIST; } ! ! /* clean temporary dl's, run request shutdown's for modules */ ! _php3_hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup); #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_LIST\n",GetCurrentThreadId()); #endif if (GLOBAL(module_initialized) & INIT_CONSTANTS) { /* clean temporary defined constants */ clean_non_persistent_constants(); } - - #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_CONSTANTS\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) { _php3_hash_destroy(&GLOBAL(include_names)); GLOBAL(initialized) &= ~INIT_INCLUDE_NAMES_HASH; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_INCLUDE_NAMES_HASH\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_SCANNER) { reset_scanner(); GLOBAL(initialized) &= ~INIT_SCANNER; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SCANNER\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_MEMORY_MANAGER) { ! shutdown_memory_manager(); } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_MEMORY_MANAGER\n",GetCurrentThreadId()); #endif if (GLOBAL(initialized)) { php3_error(E_WARNING, "Unknown resources in request shutdown function"); } php3_unset_timeout(_INLINE_TLS_VOID); #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:timer unset\n",GetCurrentThreadId()); #endif ! /* FIXME free up per-server config */ #if WIN32|WINNT ! /*_reg_free_server_config();*/ #endif /* FIXME ok we're freeing the ini now */ free(GLOBAL(php3_ini)); --- 802,859 ---- stack_destroy(&GLOBAL(variable_unassign_stack)); GLOBAL(initialized) &= ~INIT_VARIABLE_UNASSIGN_STACK; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_VARIABLE_UNASSIGN_STACK\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_LIST) { destroy_resource_list(); GLOBAL(initialized) &= ~INIT_LIST; } ! /* clean temporary dl's, run request shutdown's for modules */ ! _php3_hash_apply(&GLOBAL(module_registry), (int (*)(void *)) module_registry_cleanup); #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_LIST\n", GetCurrentThreadId()); #endif if (GLOBAL(module_initialized) & INIT_CONSTANTS) { /* clean temporary defined constants */ clean_non_persistent_constants(); } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_CONSTANTS\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_INCLUDE_NAMES_HASH) { _php3_hash_destroy(&GLOBAL(include_names)); GLOBAL(initialized) &= ~INIT_INCLUDE_NAMES_HASH; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_INCLUDE_NAMES_HASH\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_SCANNER) { reset_scanner(); GLOBAL(initialized) &= ~INIT_SCANNER; } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_SCANNER\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized) & INIT_MEMORY_MANAGER) { ! memory_manager_rshutdown(); } #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:INIT_MEMORY_MANAGER\n", GetCurrentThreadId()); #endif if (GLOBAL(initialized)) { php3_error(E_WARNING, "Unknown resources in request shutdown function"); } php3_unset_timeout(_INLINE_TLS_VOID); #if 0 && defined(CRASH_DETECTION) ! debug_log("%d:timer unset\n", GetCurrentThreadId()); #endif ! /* FIXME free up per-server config */ #if WIN32|WINNT ! /*_reg_free_server_config();*/ #endif /* FIXME ok we're freeing the ini now */ free(GLOBAL(php3_ini)); *************** *** 874,880 **** static int php3_config_ini_startup(INLINE_TLS_VOID) { php3_ini_cache_entry *p = php3_ini_cache_core; ! if (php3_init_config() == FAILURE) { php3_printf("PHP: Unable to parse configuration file.\n"); return FAILURE; --- 866,872 ---- static int php3_config_ini_startup(INLINE_TLS_VOID) { php3_ini_cache_entry *p = php3_ini_cache_core; ! if (php3_init_config() == FAILURE) { php3_printf("PHP: Unable to parse configuration file.\n"); return FAILURE; *************** *** 887,901 **** while (p->name) { switch (p->type) { case IS_STRING: ! if (ini_get_string(p->name, (char **) p->cache_address)==FAILURE) { #if 0 ! printf("'%s' -> '%s'\n", p->name,(char *) p->default_value); #endif *((char **) p->cache_address) = (char *) p->default_value; } break; case IS_LONG: ! if (ini_get_long(p->name, (long *) p->cache_address)==FAILURE) { #if 0 printf("'%s' -> %d\n", p->name, (long) p->default_value); #endif --- 879,893 ---- while (p->name) { switch (p->type) { case IS_STRING: ! if (ini_get_string(p->name, (char **) p->cache_address) == FAILURE) { #if 0 ! printf("'%s' -> '%s'\n", p->name, (char *) p->default_value); #endif *((char **) p->cache_address) = (char *) p->default_value; } break; case IS_LONG: ! if (ini_get_long(p->name, (long *) p->cache_address) == FAILURE) { #if 0 printf("'%s' -> %d\n", p->name, (long) p->default_value); #endif *************** *** 905,914 **** } p++; } ! ! #if defined(CRASH_DETECTION) ! debug_log("%d:INI OK\n",GetCurrentThreadId()); #endif return SUCCESS; } --- 897,906 ---- } p++; } ! ! #if defined(CRASH_DETECTION) ! debug_log("%d:INI OK\n", GetCurrentThreadId()); #endif return SUCCESS; } *************** *** 978,984 **** } GLOBAL(module_initialized) |= INIT_PLIST; ! if (php3_startup_constants()==FAILURE) { return FAILURE; } GLOBAL(module_initialized) |= INIT_CONSTANTS; --- 970,976 ---- } GLOBAL(module_initialized) |= INIT_PLIST; ! if (php3_startup_constants() == FAILURE) { return FAILURE; } GLOBAL(module_initialized) |= INIT_CONSTANTS; *************** *** 994,1001 **** void php3_module_shutdown_for_exec(void) { register int i; ! ! for (i=3; i<=255; i++) { close(i); } } --- 986,993 ---- void php3_module_shutdown_for_exec(void) { register int i; ! ! for (i = 3; i <= 255; i++) { close(i); } } *************** *** 1018,1029 **** php3_shutdown_constants(); GLOBAL(module_initialized) &= ~INIT_CONSTANTS; } - if (GLOBAL(module_initialized) & INIT_FUNCTION_TABLE) { _php3_hash_destroy(&GLOBAL(function_table)); GLOBAL(module_initialized) &= ~INIT_FUNCTION_TABLE; } - if (GLOBAL(module_initialized)) { php3_error(E_WARNING, "Unknown resource in module shutdown"); } --- 1010,1019 ---- *************** *** 1034,1065 **** int _php3_hash_environment(void) { char **env, *p, *t; ! unsigned char _gpc_flags[3] = {0,0,0}; pval tmp; TLS_VARS; p = GLOBAL(php3_ini)->gpc_order; ! while(*p) { ! switch(*p++) { case 'p': case 'P': if (!_gpc_flags[0] && php3_headers_unsent() && GLOBAL(sapi_rqst)->request_method && !strcasecmp(GLOBAL(sapi_rqst)->request_method, "post")) { php3_treat_data(PARSE_POST, NULL); /* POST Data */ ! _gpc_flags[0]=1; } break; case 'c': case 'C': if (!_gpc_flags[1]) { php3_treat_data(PARSE_COOKIE, NULL); /* Cookie Data */ ! _gpc_flags[1]=1; } break; case 'g': case 'G': if (!_gpc_flags[2]) { php3_treat_data(PARSE_GET, NULL); /* GET Data */ ! _gpc_flags[2]=1; } break; } --- 1024,1056 ---- int _php3_hash_environment(void) { char **env, *p, *t; ! unsigned char _gpc_flags[3] = ! {0, 0, 0}; pval tmp; TLS_VARS; p = GLOBAL(php3_ini)->gpc_order; ! while (*p) { ! switch (*p++) { case 'p': case 'P': if (!_gpc_flags[0] && php3_headers_unsent() && GLOBAL(sapi_rqst)->request_method && !strcasecmp(GLOBAL(sapi_rqst)->request_method, "post")) { php3_treat_data(PARSE_POST, NULL); /* POST Data */ ! _gpc_flags[0] = 1; } break; case 'c': case 'C': if (!_gpc_flags[1]) { php3_treat_data(PARSE_COOKIE, NULL); /* Cookie Data */ ! _gpc_flags[1] = 1; } break; case 'g': case 'G': if (!_gpc_flags[2]) { php3_treat_data(PARSE_GET, NULL); /* GET Data */ ! _gpc_flags[2] = 1; } break; } *************** *** 1082,1088 **** } ! /* this replaces server specific hashing by moving it into sapi*/ GLOBAL(sapi_rqst)->_php3_hash_server_env(SAPI_GLOBAL_PASS_V); --- 1073,1079 ---- } ! /* this replaces server specific hashing by moving it into sapi */ GLOBAL(sapi_rqst)->_php3_hash_server_env(SAPI_GLOBAL_PASS_V); *************** *** 1139,1154 **** static void php3_parse(FILE * yyin INLINE_TLS) { int original_lineno = GLOBAL(phplineno); ! ! initialize_input_file_buffer(yyin); if (GLOBAL(php3_ini)->auto_prepend_file && GLOBAL(php3_ini)->auto_prepend_file[0]) { pval tmp; ! tmp.value.str.val = GLOBAL(php3_ini)->auto_prepend_file; tmp.value.str.len = strlen(tmp.value.str.val); tmp.type = IS_STRING; ! ! include_file(&tmp,0); (void) phpparse(); } /* Call Parser on the main input file */ --- 1130,1145 ---- static void php3_parse(FILE * yyin INLINE_TLS) { int original_lineno = GLOBAL(phplineno); ! ! initialize_input_file_buffer(yyin); if (GLOBAL(php3_ini)->auto_prepend_file && GLOBAL(php3_ini)->auto_prepend_file[0]) { pval tmp; ! tmp.value.str.val = GLOBAL(php3_ini)->auto_prepend_file; tmp.value.str.len = strlen(tmp.value.str.val); tmp.type = IS_STRING; ! ! include_file(&tmp, 0); (void) phpparse(); } /* Call Parser on the main input file */ *************** *** 1158,1169 **** if (GLOBAL(php3_ini)->auto_append_file && GLOBAL(php3_ini)->auto_append_file[0]) { pval tmp; ! tmp.value.str.val = GLOBAL(php3_ini)->auto_append_file; tmp.value.str.len = strlen(tmp.value.str.val); tmp.type = IS_STRING; ! ! include_file(&tmp,0); (void) phpparse(); } } --- 1149,1160 ---- if (GLOBAL(php3_ini)->auto_append_file && GLOBAL(php3_ini)->auto_append_file[0]) { pval tmp; ! tmp.value.str.val = GLOBAL(php3_ini)->auto_append_file; tmp.value.str.len = strlen(tmp.value.str.val); tmp.type = IS_STRING; ! ! include_file(&tmp, 0); (void) phpparse(); } } *************** *** 1209,1215 **** extern flex_globals *yy_init_tls(void); extern void yy_destroy_tls(void); #endif ! extern int _php3_load_module(php3_module_entry *module_entry, void *handle); /* --- 1200,1206 ---- extern flex_globals *yy_init_tls(void); extern void yy_destroy_tls(void); #endif ! extern int _php3_load_module(php3_module_entry * module_entry, void *handle); /* *************** *** 1232,1243 **** extern void _reg_clear_cache(void); #endif ! PHPAPI int _php3_sapi_process_start(php3_module_entry *module_info){ #ifdef THREAD_SAFE php3_globals_struct *php3_globals; #endif #if WIN32|WINNT ! _fmode = _O_BINARY; /*sets default for file streams to binary */ /* make the stdio mode be binary */ setmode(_fileno(stdin), O_BINARY); setmode(_fileno(stdout), O_BINARY); --- 1223,1238 ---- extern void _reg_clear_cache(void); #endif ! PHPAPI int _php3_sapi_process_start(php3_module_entry * module_info) ! { #ifdef THREAD_SAFE php3_globals_struct *php3_globals; #endif + + start_memory_manager(); + #if WIN32|WINNT ! _fmode = _O_BINARY; /* sets default for file streams to binary */ /* make the stdio mode be binary */ setmode(_fileno(stdin), O_BINARY); setmode(_fileno(stdout), O_BINARY); *************** *** 1247,1253 **** setlocale(LC_CTYPE, ""); #endif #if defined(CRASH_DETECTION) ! debug_log("########################\n%d:Process Start\n",GetCurrentThreadId()); #endif #ifdef THREAD_SAFE --- 1242,1248 ---- setlocale(LC_CTYPE, ""); #endif #if defined(CRASH_DETECTION) ! debug_log("########################\n%d:Process Start\n", GetCurrentThreadId()); #endif #ifdef THREAD_SAFE *************** *** 1256,1309 **** #endif PHP3_MUTEX_ALLOC(gLock); PHP3_CRITICAL_ALLOC(Tls_crit); ! if (!PHP3_TLS_PROC_STARTUP(TlsIndex))return 0; ! if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0; ! PHP3_TLS_GET(TlsIndex,php3_globals); ! if(!php3_globals){ #if defined(CRASH_DETECTION) ! debug_log("%d:Process Start Could not get TLS VAR!\n",GetCurrentThreadId()); #endif return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:TLS Init Success\n",GetCurrentThreadId()); #endif ! if(!yy_init_tls()) return 0; ! ! php3_globals->sapi_rqst=NULL; ! #endif /* THREAD SAFE*/ /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini)=_php3_copy_ini_master(); ! start_memory_manager(); if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) { ! shutdown_memory_manager(); free(GLOBAL(php3_ini)); return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:INI Load Success\n",GetCurrentThreadId()); #endif if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE) { ! shutdown_memory_manager(); return 0; } ! ! /*load dl's from ini file*/ #ifdef THREAD_SAFE php3_dlload(_INLINE_TLS_VOID); #endif ! /*need to register server specific functions*/ ! if(module_info){ ! module_info->type=MODULE_PERSISTENT; ! _php3_load_module(module_info,NULL); } - #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Load Success\n########################\n",GetCurrentThreadId()); #endif ! shutdown_memory_manager(); free(GLOBAL(php3_ini)); return 1; } --- 1251,1307 ---- #endif PHP3_MUTEX_ALLOC(gLock); PHP3_CRITICAL_ALLOC(Tls_crit); ! ! if (!PHP3_TLS_PROC_STARTUP(TlsIndex)) { ! return 0; ! } ! ! if (!PHP3_TLS_THREAD_INIT(TlsIndex, php3_globals, php3_globals_struct)) { ! return 0; ! } ! PHP3_TLS_GET(TlsIndex, php3_globals); ! if (!php3_globals) { #if defined(CRASH_DETECTION) ! debug_log("%d:Process Start Could not get TLS VAR!\n", GetCurrentThreadId()); #endif return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:TLS Init Success\n", GetCurrentThreadId()); #endif ! if (!yy_init_tls()) return 0; ! ! php3_globals->sapi_rqst = NULL; ! #endif /* THREAD SAFE */ /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini) = _php3_copy_ini_master(); if (php3_config_ini_startup(_INLINE_TLS_VOID) == FAILURE) { ! memory_manager_rshutdown(); free(GLOBAL(php3_ini)); return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:INI Load Success\n", GetCurrentThreadId()); #endif if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE) { ! memory_manager_rshutdown(); return 0; } ! /* load dl's from ini file */ #ifdef THREAD_SAFE php3_dlload(_INLINE_TLS_VOID); #endif ! /* need to register server specific functions */ ! if (module_info) { ! module_info->type = MODULE_PERSISTENT; ! _php3_load_module(module_info, NULL); } #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Load Success\n########################\n", GetCurrentThreadId()); #endif ! memory_manager_rshutdown(); free(GLOBAL(php3_ini)); return 1; } *************** *** 1316,1365 **** * same time. * */ ! PHPAPI int _php3_sapi_thread_start(php3_module_entry *module_info){ #ifdef THREAD_SAFE php3_globals_struct *php3_globals; #if defined(CRASH_DETECTION) ! debug_log("########################\n%d:Thread Start\n",GetCurrentThreadId()); #endif ! if (!PHP3_TLS_THREAD_INIT(TlsIndex,php3_globals,php3_globals_struct))return 0; ! PHP3_TLS_GET(TlsIndex,php3_globals); ! if(!php3_globals){ #if defined(CRASH_DETECTION) ! debug_log("%d:Could not get TLS VAR!\n########################\n",GetCurrentThreadId()); #endif return 0; } ! if(!yy_init_tls())return 0; ! php3_globals->sapi_rqst=NULL; ! #endif /* THREAD SAFE */ #if WIN32|WINNT ! _fmode = _O_BINARY; /*sets default for file streams to binary */ #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini)=_php3_copy_ini_master(); ! start_memory_manager(); ! if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE){ ! shutdown_memory_manager(); return 0; } ! ! /*load dl's from ini file*/ #ifdef THREAD_SAFE php3_dlload(_INLINE_TLS_VOID); #endif ! /*register server specific functions*/ ! if(module_info){ ! module_info->type=MODULE_PERSISTENT; ! _php3_load_module(module_info,NULL); } ! ! shutdown_memory_manager(); free(GLOBAL(php3_ini)); #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Thread Start Success\n########################\n",GetCurrentThreadId()); #endif return 1; } --- 1314,1372 ---- * same time. * */ ! PHPAPI int _php3_sapi_thread_start(php3_module_entry * module_info) ! { #ifdef THREAD_SAFE php3_globals_struct *php3_globals; + #endif + + start_memory_manager(); + + #ifdef THREAD_SAFE #if defined(CRASH_DETECTION) ! debug_log("########################\n%d:Thread Start\n", GetCurrentThreadId()); #endif ! ! if (!PHP3_TLS_THREAD_INIT(TlsIndex, php3_globals, php3_globals_struct)) { ! return 0; ! } ! PHP3_TLS_GET(TlsIndex, php3_globals); ! if (!php3_globals) { #if defined(CRASH_DETECTION) ! debug_log("%d:Could not get TLS VAR!\n########################\n", GetCurrentThreadId()); #endif return 0; } ! if (!yy_init_tls()) ! return 0; ! ! php3_globals->sapi_rqst = NULL; ! #endif /* THREAD SAFE */ ! #if WIN32|WINNT ! _fmode = _O_BINARY; /*sets default for file streams to binary */ #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini) = _php3_copy_ini_master(); ! if (php3_module_startup(_INLINE_TLS_VOID) == FAILURE) { ! memory_manager_rshutdown(); return 0; } ! /*load dl's from ini file */ #ifdef THREAD_SAFE php3_dlload(_INLINE_TLS_VOID); #endif ! /*register server specific functions */ ! if (module_info) { ! module_info->type = MODULE_PERSISTENT; ! _php3_load_module(module_info, NULL); } ! memory_manager_rshutdown(); free(GLOBAL(php3_ini)); #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Thread Start Success\n########################\n", GetCurrentThreadId()); #endif return 1; } *************** *** 1367,1389 **** /* * sapi thread end */ ! PHPAPI int _php3_sapi_thread_end(void){ #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex,php3_globals); ! /* see sapi dllmain() for info*/ ! if(!php3_globals)return 1; #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini)=_php3_copy_ini_master(); php3_module_shutdown(_INLINE_TLS_VOID); ! if(GLOBAL(php3_ini))free(GLOBAL(php3_ini)); #ifdef THREAD_SAFE PHP3_TLS_THREAD_FREE(php3_globals); yy_destroy_tls(); #endif #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Thread End Success\n",GetCurrentThreadId()); #endif return 1; } --- 1374,1399 ---- /* * sapi thread end */ ! PHPAPI int _php3_sapi_thread_end(void) ! { #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex, php3_globals); ! /* see sapi dllmain() for info */ ! if (!php3_globals) ! return 1; #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini) = _php3_copy_ini_master(); php3_module_shutdown(_INLINE_TLS_VOID); ! if (GLOBAL(php3_ini)) ! free(GLOBAL(php3_ini)); #ifdef THREAD_SAFE PHP3_TLS_THREAD_FREE(php3_globals); yy_destroy_tls(); #endif #if defined(CRASH_DETECTION) ! debug_log("%d:DLL Thread End Success\n", GetCurrentThreadId()); #endif return 1; } *************** *** 1391,1403 **** /* * sapi process end */ ! PHPAPI int _php3_sapi_process_end(void){ #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex,php3_globals); #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini)=_php3_copy_ini_master(); php3_module_shutdown(_INLINE_TLS_VOID); free(GLOBAL(php3_ini)); --- 1401,1414 ---- /* * sapi process end */ ! PHPAPI int _php3_sapi_process_end(void) ! { #ifdef THREAD_SAFE php3_globals_struct *php3_globals; ! PHP3_TLS_GET(TlsIndex, php3_globals); #endif /* make a temporary php3_ini for startup */ ! GLOBAL(php3_ini) = _php3_copy_ini_master(); php3_module_shutdown(_INLINE_TLS_VOID); free(GLOBAL(php3_ini)); *************** *** 1407,1413 **** PHP3_TLS_PROC_SHUTDOWN(TlsIndex); yy_destroy_tls(); #if defined(CRASH_DETECTION) ! debug_log("%d:DLL UNLoad Success\n",GetCurrentThreadId()); #endif #if WIN32|WINNT _reg_clear_cache(); --- 1418,1424 ---- PHP3_TLS_PROC_SHUTDOWN(TlsIndex); yy_destroy_tls(); #if defined(CRASH_DETECTION) ! debug_log("%d:DLL UNLoad Success\n", GetCurrentThreadId()); #endif #if WIN32|WINNT _reg_clear_cache(); *************** *** 1424,1430 **** * sapi main. called each request from the server interface file (sapi) */ ! PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info, php3_module_entry *module_info) { int c; FILE *in = NULL; --- 1435,1441 ---- * sapi main. called each request from the server interface file (sapi) */ ! PHPAPI int php3_sapi_main(struct sapi_request_info *sapi_info, php3_module_entry * module_info) { int c; FILE *in = NULL; *************** *** 1435,1494 **** #ifdef THREAD_SAFE ! # if defined(CRASH_DETECTION) ! debug_log("%d:main entered\n",GetCurrentThreadId()); ! if (!TlsIndex) { ! debug_log("%d:Invalid TLSIndex!\n",GetCurrentThreadId()); ! } ! # endif ! if(TlsIndex) { ! PHP3_TLS_GET(TlsIndex,php3_globals); } else { return FAILURE; } ! # if defined(CRASH_DETECTION) ! debug_log("%d:main tls initialized\n",GetCurrentThreadId()); ! # endif if (!php3_globals) { /* uninitialized thread, initialize now */ _php3_sapi_thread_start(module_info); ! PHP3_TLS_GET(TlsIndex,php3_globals); ! if(!php3_globals){ /* ! something is realy screwed up if we get here. ! send output to the browser manualy, because nothing in ! php is or can be initialized, but we can because sapi ! is (should be) initialized ! */ sapi_info->send_header(SAPI_GLOBAL_PASS_V); PUTS("IIS Internal Error: Thread could not initialized!"); return SUCCESS; } } ! PHP3_TLS_GET(phpLexTlsIndex,php_gbl); #endif ! GLOBAL(php3_preprocess) = sapi_info->preprocess; GLOBAL(php3_display_source) = sapi_info->display_source_mode; GLOBAL(sapi_rqst) = sapi_info; GLOBAL(sapi_rqst)->buffered_output = 0; ! GLOBAL(client_alive)=1; #if defined(CRASH_DETECTION) ! debug_log("%d:enter request startup\n",GetCurrentThreadId()); #endif if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) { ! if(GLOBAL(php3_ini))free(GLOBAL(php3_ini)); return FAILURE; } - php3_treat_headers(_INLINE_TLS_VOID); #if defined(CRASH_DETECTION) ! debug_log("%d:request startup success\n",GetCurrentThreadId()); #endif /* now we estrdup the rqst_filename into filename so the include hash works right */ ! if(sapi_info->rqst_filename)sapi_info->filename=estrdup(sapi_info->rqst_filename); if (sapi_info->preprocess == PREPROCESS_PREPROCESS || sapi_info->quiet_mode) { php3_noheader(); --- 1446,1506 ---- #ifdef THREAD_SAFE ! #if defined(CRASH_DETECTION) ! debug_log("%d:main entered\n", GetCurrentThreadId()); ! if (!TlsIndex) { ! debug_log("%d:Invalid TLSIndex!\n", GetCurrentThreadId()); ! } ! #endif ! if (TlsIndex) { ! PHP3_TLS_GET(TlsIndex, php3_globals); } else { return FAILURE; } ! #if defined(CRASH_DETECTION) ! debug_log("%d:main tls initialized\n", GetCurrentThreadId()); ! #endif if (!php3_globals) { /* uninitialized thread, initialize now */ _php3_sapi_thread_start(module_info); ! PHP3_TLS_GET(TlsIndex, php3_globals); ! if (!php3_globals) { /* ! something is realy screwed up if we get here. ! send output to the browser manualy, because nothing in ! php is or can be initialized, but we can because sapi ! is (should be) initialized ! */ sapi_info->send_header(SAPI_GLOBAL_PASS_V); PUTS("IIS Internal Error: Thread could not initialized!"); return SUCCESS; } } ! PHP3_TLS_GET(phpLexTlsIndex, php_gbl); #endif ! GLOBAL(php3_preprocess) = sapi_info->preprocess; GLOBAL(php3_display_source) = sapi_info->display_source_mode; GLOBAL(sapi_rqst) = sapi_info; GLOBAL(sapi_rqst)->buffered_output = 0; ! GLOBAL(client_alive) = 1; #if defined(CRASH_DETECTION) ! debug_log("%d:enter request startup\n", GetCurrentThreadId()); #endif if (php3_request_startup(_INLINE_TLS_VOID) == FAILURE) { ! if (GLOBAL(php3_ini)) ! free(GLOBAL(php3_ini)); return FAILURE; } php3_treat_headers(_INLINE_TLS_VOID); #if defined(CRASH_DETECTION) ! debug_log("%d:request startup success\n", GetCurrentThreadId()); #endif /* now we estrdup the rqst_filename into filename so the include hash works right */ ! if (sapi_info->rqst_filename) ! sapi_info->filename = estrdup(sapi_info->rqst_filename); if (sapi_info->preprocess == PREPROCESS_PREPROCESS || sapi_info->quiet_mode) { php3_noheader(); *************** *** 1498,1509 **** php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return (1); } - /* if its not cgi, require that we have a filename now */ if (!sapi_info->cgi && !sapi_info->filename) { ! if(sapi_info->interactive){ ! GLOBAL(phpin)=stdin; ! }else{ php3_printf("No input file specified.\n"); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return 0; --- 1510,1520 ---- php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return (1); } /* if its not cgi, require that we have a filename now */ if (!sapi_info->cgi && !sapi_info->filename) { ! if (sapi_info->interactive) { ! GLOBAL(phpin) = stdin; ! } else { php3_printf("No input file specified.\n"); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return 0; *************** *** 1515,1535 **** if it is null at this point */ #if defined(CRASH_DETECTION) ! debug_log("%d:opening file %s\n",GetCurrentThreadId(),sapi_info->filename); #endif ! if(sapi_info->cgi || sapi_info->filename){ in = php3_fopen_for_parser(); } else if (sapi_info->interactive) { ! sapi_info->filename=estrdup("stdin"); } - if (sapi_info->cgi && !in) { php3_printf("No input file specified for cgi.\n"); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:opening file success\n",GetCurrentThreadId()); #endif if (sapi_info->cgi && in) { /* #!php support */ --- 1526,1545 ---- if it is null at this point */ #if defined(CRASH_DETECTION) ! debug_log("%d:opening file %s\n", GetCurrentThreadId(), sapi_info->filename); #endif ! if (sapi_info->cgi || sapi_info->filename) { in = php3_fopen_for_parser(); } else if (sapi_info->interactive) { ! sapi_info->filename = estrdup("stdin"); } if (sapi_info->cgi && !in) { php3_printf("No input file specified for cgi.\n"); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); return 0; } #if defined(CRASH_DETECTION) ! debug_log("%d:opening file success\n", GetCurrentThreadId()); #endif if (sapi_info->cgi && in) { /* #!php support */ *************** *** 1552,1560 **** GLOBAL(php3_display_source) = 1; if (!php3_header()) free(GLOBAL(php3_ini)); ! exit(0); PUTS("<html><head><title>Source for "); ! if(sapi_info->filename) { PUTS(sapi_info->filename); } else { PUTS("unknown"); --- 1562,1570 ---- GLOBAL(php3_display_source) = 1; if (!php3_header()) free(GLOBAL(php3_ini)); ! exit(0); PUTS("<html><head><title>Source for "); ! if (sapi_info->filename) { PUTS(sapi_info->filename); } else { PUTS("unknown"); *************** *** 1570,1606 **** return 0; } if (sapi_info->preprocess == PREPROCESS_EXECUTE) { ! tcm_load(&GLOBAL(token_cache_manager),GLOBAL(phpin)); GLOBAL(php3_preprocess) = PREPROCESS_NONE; } ! if (sapi_info->preprocess==PREPROCESS_NONE) { #if defined(CRASH_DETECTION) ! debug_log("%d:begin parse\n",GetCurrentThreadId()); #endif #if defined(USE_EXCEPTION) ! __try{ ! /*use an exception handler here to try and protect ! against dl's that may be bad*/ #endif ! if(in)GLOBAL(phpin)=in; ! php3_parse(GLOBAL(phpin) _INLINE_TLS); #if defined(USE_EXCEPTION) ! } __except(EXCEPTION_EXECUTE_HANDLER) { ! int i=0; /*dummy statement*/ #if MSVC5 ! char logmessage[80]; ! snprintf(logmessage, 79, "%d:php3_parse exception\n", GetCurrentThreadId()); ! OutputDebugString(logmessage); #endif ! /*lets let this request try to shut down normaly*/ ! } #endif #if defined(CRASH_DETECTION) ! debug_log("%d:parse done\n",GetCurrentThreadId()); #endif } else { pval yylval; --- 1580,1618 ---- return 0; } if (sapi_info->preprocess == PREPROCESS_EXECUTE) { ! tcm_load(&GLOBAL(token_cache_manager), GLOBAL(phpin)); GLOBAL(php3_preprocess) = PREPROCESS_NONE; } ! if (sapi_info->preprocess == PREPROCESS_NONE) { #if defined(CRASH_DETECTION) ! debug_log("%d:begin parse\n", GetCurrentThreadId()); #endif #if defined(USE_EXCEPTION) ! __try { ! /*use an exception handler here to try and protect ! against dl's that may be bad */ #endif ! if (in) ! GLOBAL(phpin) = in; ! php3_parse(GLOBAL(phpin) _INLINE_TLS); #if defined(USE_EXCEPTION) ! } ! __except(EXCEPTION_EXECUTE_HANDLER) { ! int i = 0; /*dummy statement */ #if MSVC5 ! char logmessage[80]; ! snprintf(logmessage, 79, "%d:php3_parse exception\n", GetCurrentThreadId()); ! OutputDebugString(logmessage); #endif ! /*lets let this request try to shut down normaly */ ! } #endif #if defined(CRASH_DETECTION) ! debug_log("%d:parse done\n", GetCurrentThreadId()); #endif } else { pval yylval; *************** *** 1618,1632 **** } if (GLOBAL(initialized)) { #if defined(CRASH_DETECTION) ! debug_log("%d:start request shutdown\n",GetCurrentThreadId()); #endif php3_header(); /* Make sure headers have been sent */ php3_call_shutdown_functions(); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); #if defined(CRASH_DETECTION) ! debug_log("%d:request shutdown done\n",GetCurrentThreadId()); #endif ! // GLOBAL(sapi_rqst=NULL); return SUCCESS; } else { return FAILURE; --- 1630,1644 ---- } if (GLOBAL(initialized)) { #if defined(CRASH_DETECTION) ! debug_log("%d:start request shutdown\n", GetCurrentThreadId()); #endif php3_header(); /* Make sure headers have been sent */ php3_call_shutdown_functions(); php3_request_shutdown((void *) GLOBAL(sapi_rqst) _INLINE_TLS); #if defined(CRASH_DETECTION) ! debug_log("%d:request shutdown done\n", GetCurrentThreadId()); #endif ! // GLOBAL(sapi_rqst=NULL); return SUCCESS; } else { return FAILURE; Index: php31/main/main.h diff -c php31/main/main.h:2.7 php31/main/main.h:2.8 *** php31/main/main.h:2.7 Tue Aug 25 23:14:20 1998 --- php31/main/main.h Tue Sep 22 10:25:35 1998 *************** *** 29,35 **** */ ! /* $Id: main.h,v 2.7 1998/08/26 03:14:20 shane Exp $ */ #ifndef _MAIN_H --- 29,35 ---- */ ! /* $Id: main.h,v 2.8 1998/09/22 14:25:35 zeev Exp $ */ #ifndef _MAIN_H *************** *** 83,88 **** --- 83,89 ---- #ifndef THREAD_SAFE extern int shutdown_requested; + extern int module_initialized; extern int initialized; extern unsigned char header_is_being_sent; #endif -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1380) next »