CVS update: php3/functions

From: Date: Fri, 23 Oct 1998 20:07:17 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1992@lists.php.net to get a copy of this message
Date: Friday October 23, 1998 @ 16:07 Author: shane Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv13501/functions Modified Files: db.c xml.c Log Message: add the proper thread safe stuff to xml. Index: php3/functions/db.c diff -c php3/functions/db.c:1.78 php3/functions/db.c:1.79 *** php3/functions/db.c:1.78 Sat Oct 17 17:41:04 1998 --- php3/functions/db.c Fri Oct 23 16:07:15 1998 *************** *** 28,34 **** +----------------------------------------------------------------------+ */ ! /* $Id: db.c,v 1.78 1998/10/17 21:41:04 shane Exp $ */ #define IS_EXT_MODULE #if COMPILE_DL #ifdef PHP_31 --- 28,34 ---- +----------------------------------------------------------------------+ */ ! /* $Id: db.c,v 1.79 1998/10/23 20:07:15 shane Exp $ */ #define IS_EXT_MODULE #if COMPILE_DL #ifdef PHP_31 *************** *** 270,276 **** void php3_dbmopen(INTERNAL_FUNCTION_PARAMETERS) { pval *filename, *mode; ! dbm_info *info; int ret; DBM_TLS_VARS; --- 270,276 ---- void php3_dbmopen(INTERNAL_FUNCTION_PARAMETERS) { pval *filename, *mode; ! dbm_info *info=NULL; int ret; DBM_TLS_VARS; *************** *** 302,308 **** int retries = 0; #endif ! DBM_TYPE dbf; DBM_MODE_TYPE imode; if (filename == NULL) { --- 302,308 ---- int retries = 0; #endif ! DBM_TYPE dbf=NULL; DBM_MODE_TYPE imode; if (filename == NULL) { *************** *** 376,381 **** --- 376,382 ---- #endif /* else NFS_HACK */ } + dbf = DBM_OPEN(filename, imode); #if !NDBM && !GDBM Index: php3/functions/xml.c diff -c php3/functions/xml.c:1.6 php3/functions/xml.c:1.7 *** php3/functions/xml.c:1.6 Fri Oct 23 07:18:22 1998 --- php3/functions/xml.c Fri Oct 23 16:07:16 1998 *************** *** 27,38 **** +----------------------------------------------------------------------+ */ ! /* $Id: xml.c,v 1.6 1998/10/23 11:18:22 ssb Exp $ */ ! #include "php.h" #include "internal_functions.h" #include "php3_xml.h" #if HAVE_LIBEXPAT # include "php3_list.h" --- 27,49 ---- +----------------------------------------------------------------------+ */ ! /* $Id: xml.c,v 1.7 1998/10/23 20:07:16 shane Exp $ */ ! #define IS_EXT_MODULE ! #if COMPILE_DL ! # if PHP_31 ! # include "dl/phpdl.h" ! # else ! # include "../phpdl.h ! # endif ! #endif #include "php.h" #include "internal_functions.h" #include "php3_xml.h" + #if defined(THREAD_SAFE) && !PHP_31 + #undef THREAD_SAFE + #endif + #if HAVE_LIBEXPAT # include "php3_list.h" *************** *** 60,67 **** # ifdef THREAD_SAFE # define XML_GLOBAL(a) xml_globals->a ! # define XML_TLS_VARS \ ! xml_global_struct *xml_globals = TlsGetValue(XMLTls); void *xml_mutex; DWORD XMLTls; --- 71,77 ---- # ifdef THREAD_SAFE # define XML_GLOBAL(a) xml_globals->a ! # define XML_TLS_VARS xml_global_struct *xml_globals = TlsGetValue(XMLTls); void *xml_mutex; DWORD XMLTls; *************** *** 83,117 **** /* {{{ dynamically loadable module stuff */ # if COMPILE_DL ! ! php3_module_entry *get_module() { return &xml_module_entry; }; ! ! # if (WIN32|WINNT) && defined(THREAD_SAFE) ! ! /* NOTE: You should have an xml.def file where you export DllMain */ ! BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, ! LPVOID lpReserved) ! { ! switch (ul_reason_for_call) { ! case DLL_PROCESS_ATTACH: ! if ((XMLTls = TlsAlloc()) == 0xFFFFFFFF){ ! return 0; ! } ! break; ! case DLL_THREAD_ATTACH: ! break; ! case DLL_THREAD_DETACH: ! break; ! case DLL_PROCESS_DETACH: ! if (!TlsFree(XMLTls)) { ! return 0; ! } ! break; ! } ! return 1; ! } ! ! # endif /* thread safe on Windows */ # endif /* COMPILE_DL */ /* }}} */ --- 93,99 ---- /* {{{ dynamically loadable module stuff */ # if COMPILE_DL ! DLEXPORT php3_module_entry *get_module() { return &xml_module_entry; }; # endif /* COMPILE_DL */ /* }}} */ *************** *** 184,209 **** int php3_minit_xml(INIT_FUNC_ARGS) { ! #ifdef THREAD_SAFE xml_global_struct *xml_globals; ! # if !COMPILE_DL ! # if WIN32|WINNT ! CREATE_MUTEX(xml_mutex,"XML_TLS"); ! # endif ! SET_MUTEX(xml_mutex); numthreads++; ! if (numthreads == 1) { ! if ((XMLTls = TlsAlloc()) == 0xFFFFFFFF){ ! FREE_MUTEX(xml_mutex); ! return 0; } } ! FREE_MUTEX(xml_mutex); ! # endif /* !COMPILE_DL */ ! xml_globals = ! (xml_global_struct *) LocalAlloc(LPTR, sizeof(xml_global_struct)); ! TlsSetValue(XMLTls, (void *) xml_globals); ! #endif /* THREAD_SAFE */ XML_GLOBAL(php3_xml_module).le_xml_parser = register_list_destructors(xml_destroy_parser, NULL); --- 166,189 ---- int php3_minit_xml(INIT_FUNC_ARGS) { ! #if defined(THREAD_SAFE) xml_global_struct *xml_globals; ! PHP3_MUTEX_ALLOC(xml_mutex); ! PHP3_MUTEX_LOCK(xml_mutex); numthreads++; ! if (numthreads==1){ ! if (!PHP3_TLS_PROC_STARTUP(XMLTls)){ ! PHP3_MUTEX_UNLOCK(xml_mutex); ! PHP3_MUTEX_FREE(xml_mutex); ! return FAILURE; } } ! PHP3_MUTEX_UNLOCK(xml_mutex); ! if(!PHP3_TLS_THREAD_INIT(XMLTls,xml_globals,xml_global_struct)){ ! PHP3_MUTEX_FREE(xml_mutex); ! return FAILURE; ! } ! #endif XML_GLOBAL(php3_xml_module).le_xml_parser = register_list_destructors(xml_destroy_parser, NULL); *************** *** 249,271 **** int php3_mshutdown_xml() { #ifdef THREAD_SAFE ! xml_global_struct *xml_globals; ! xml_globals = TlsGetValue(XMLTls); ! if (xml_globals != 0) { ! LocalFree((HLOCAL) xml_globals); ! } ! #if !COMPILE_DL ! SET_MUTEX(xml_mutex); numthreads--; ! if (!numthreads) { ! if (!TlsFree(XMLTls)) { ! FREE_MUTEX(xml_mutex); ! return 0; ! } } ! FREE_MUTEX(xml_mutex); ! #endif #endif return SUCCESS; } --- 229,246 ---- int php3_mshutdown_xml() { + XML_TLS_VARS; #ifdef THREAD_SAFE ! PHP3_TLS_THREAD_FREE(xml_globals); ! PHP3_MUTEX_LOCK(xml_mutex); numthreads--; ! if (numthreads<1) { ! PHP3_TLS_PROC_SHUTDOWN(XMLTls); ! PHP3_MUTEX_UNLOCK(xml_mutex); ! PHP3_MUTEX_FREE(xml_mutex); ! return SUCCESS; } ! PHP3_MUTEX_UNLOCK(xml_mutex); #endif return SUCCESS; } -- 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 (#1992) next »