CVS update: php31/ext/odbc

From: Date: Fri, 28 Aug 1998 20:35:26 +0000
Subject: CVS update: php31/ext/odbc
Groups: php.dev 
Request: Send a blank email to php-dev+get-643@lists.php.net to get a copy of this message
Date: Friday August 28, 1998 @ 16:35 Author: shane Update of /repository/php31/ext/odbc In directory asf:/u2/tmp/cvs-serv14420/ext/odbc Modified Files: unified_odbc.c Log Message: fix some major threading issues in our dl functions. odbc was loading m$ odbc dlls which created new threads, and calling our dllmain which would then initialize php all over. A LOT of overhead is now gone. Still trying to figure out why certain odbc support dlls are getting loaded with each hit, even though were no longer calling dlopen on each thread. Also fixes to scanners for my flex fix Index: php31/ext/odbc/unified_odbc.c diff -c php31/ext/odbc/unified_odbc.c:2.6 php31/ext/odbc/unified_odbc.c:2.7 *** php31/ext/odbc/unified_odbc.c:2.6 Fri Aug 28 00:09:38 1998 --- php31/ext/odbc/unified_odbc.c Fri Aug 28 16:35:25 1998 *************** *** 55,61 **** #define IS_EXT_MODULE #ifdef THREAD_SAFE ! void *UODBC_MUTEX; DWORD UODBC_TLS; static int numthreads=0; --- 55,61 ---- #define IS_EXT_MODULE #ifdef THREAD_SAFE ! MUTEX_T UODBC_MUTEX; DWORD UODBC_TLS; static int numthreads=0; *************** *** 124,130 **** #if COMPILE_DL DLEXPORT php3_module_entry *get_module() { return &UODBC_MODULE_ENTRY; }; ! #if (WIN32|WINNT) && defined(THREAD_SAFE) /*NOTE: You should have an odbc.def file where you export DllMain*/ --- 124,130 ---- #if COMPILE_DL DLEXPORT php3_module_entry *get_module() { return &UODBC_MODULE_ENTRY; }; ! #if 0 /*NOTE: You should have an odbc.def file where you export DllMain*/ *************** *** 218,231 **** #endif #ifdef THREAD_SAFE UODBC_GLOBAL_STRUCT *UODBC_GLOBALS; numthreads++; if (numthreads==1){ ! if ((UODBC_TLS=TlsAlloc())==0xFFFFFFFF){ ! return 0; ! }} ! UODBC_GLOBALS = ! (UODBC_GLOBAL_STRUCT *) LocalAlloc(LPTR, sizeof(UODBC_GLOBAL_STRUCT)); ! TlsSetValue(UODBC_TLS, (void *) UODBC_GLOBALS); #endif SQLAllocEnv(&UODBC_GLOBAL(PHP3_UODBC_MODULE).henv); --- 218,240 ---- #endif #ifdef THREAD_SAFE UODBC_GLOBAL_STRUCT *UODBC_GLOBALS; + PHP3_MUTEX_ALLOC(UODBC_MUTEX); + PHP3_MUTEX_LOCK(UODBC_MUTEX); numthreads++; if (numthreads==1){ ! if (!PHP3_TLS_PROC_STARTUP(UODBC_TLS)){ ! OutputDebugString("ODBC TLS PROC FAILURE!\n"); ! PHP3_MUTEX_UNLOCK(UODBC_MUTEX); ! PHP3_MUTEX_FREE(UODBC_MUTEX); ! return FAILURE; ! } ! } ! PHP3_MUTEX_UNLOCK(UODBC_MUTEX); ! if(!PHP3_TLS_THREAD_INIT(UODBC_TLS,UODBC_GLOBALS,UODBC_GLOBAL_STRUCT)){ ! OutputDebugString("ODBC TLS THREAD FAILURE!\n"); ! PHP3_MUTEX_FREE(UODBC_MUTEX); ! return FAILURE; ! } #endif SQLAllocEnv(&UODBC_GLOBAL(PHP3_UODBC_MODULE).henv); *************** *** 299,324 **** return SUCCESS; } ! int PHP3_MSHUTDOWN_UODBC(void) ! { #ifdef THREAD_SAFE ! UODBC_GLOBAL_STRUCT *UODBC_GLOBALS; ! UODBC_GLOBALS = TlsGetValue(UODBC_TLS); #endif ! SQLFreeEnv(&UODBC_GLOBAL(PHP3_UODBC_MODULE).henv); ! #ifdef THREAD_SAFE ! if (UODBC_GLOBALS != 0) { ! LocalFree((HLOCAL) UODBC_GLOBALS); } numthreads--; ! if (!numthreads) { ! if (!TlsFree(UODBC_TLS)) { ! return FAILURE; ! } } #endif return SUCCESS; } void PHP3_INFO_UODBC(void) --- 308,341 ---- return SUCCESS; } ! int PHP3_MSHUTDOWN_UODBC(void){ ! UODBC_TLS_VARS; #ifdef THREAD_SAFE ! #if DEBUG ! if(numthreads<0){ ! /*ok this is a real problem!*/ ! #if MSVC5 ! char logmessage[80]; ! snprintf(logmessage, 79, "%d:uodbc mshutdown numthreads error!\n", GetCurrentThreadId()); ! OutputDebugString(logmessage); #endif ! return FAILURE; } + #endif + PHP3_TLS_THREAD_FREE(UODBC_GLOBALS); + PHP3_MUTEX_LOCK(UODBC_MUTEX); numthreads--; ! if (numthreads<1) { ! PHP3_TLS_PROC_SHUTDOWN(UODBC_TLS); ! PHP3_MUTEX_UNLOCK(UODBC_MUTEX); ! PHP3_MUTEX_FREE(UODBC_MUTEX); ! return SUCCESS; } + PHP3_MUTEX_UNLOCK(UODBC_MUTEX); #endif return SUCCESS; } + void PHP3_INFO_UODBC(void) -- 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 (#643) next »