cvs: php4 /ext/mbstring mbregex.c mbstring.c

From: Date: Tue, 08 Oct 2002 17:20:16 +0000
Subject: cvs: php4 /ext/mbstring mbregex.c mbstring.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-14718@lists.php.net to get a copy of this message
moriyoshi Tue Oct 8 13:20:16 2002 EDT Modified files: /php4/ext/mbstring mbregex.c mbstring.c Log: ZTS fixes Index: php4/ext/mbstring/mbregex.c diff -u php4/ext/mbstring/mbregex.c:1.13 php4/ext/mbstring/mbregex.c:1.14 --- php4/ext/mbstring/mbregex.c:1.13 Tue Oct 8 11:15:50 2002 +++ php4/ext/mbstring/mbregex.c Tue Oct 8 13:20:08 2002 @@ -306,9 +306,16 @@ register int c; static int done = 0; +#ifdef ZTS + extern MUTEX_T mbregex_locale_mutex; +#endif + if (done) { return; } +#ifdef ZTS + tsrm_mutex_lock( mbregex_locale_mutex ); +#endif memset(re_syntax_table, 0, sizeof(re_syntax_table)); @@ -324,6 +331,9 @@ re_syntax_table[c] = Sword2; } } +#ifdef ZTS + tsrm_mutex_unlock( mbregex_locale_mutex ); +#endif done = 1; } Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.100 php4/ext/mbstring/mbstring.c:1.101 --- php4/ext/mbstring/mbstring.c:1.100 Mon Oct 7 13:59:48 2002 +++ php4/ext/mbstring/mbstring.c Tue Oct 8 13:20:10 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.100 2002/10/07 17:59:48 moriyoshi Exp $ */ +/* $Id: mbstring.c,v 1.101 2002/10/08 17:20:10 moriyoshi Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -65,6 +65,7 @@ #include "php_content_types.h" #include "SAPI.h" #include "php_unicode.h" +#include "TSRM.h" #ifdef ZEND_MULTIBYTE #include "zend_multibyte.h" @@ -76,6 +77,10 @@ #include "mbregex.h" #endif +#ifdef ZTS +MUTEX_T mbregex_locale_mutex = NULL; +#endif + #if defined(HAVE_MBSTR_JA) static const enum mbfl_no_encoding php_mbstr_default_identify_list[] = { mbfl_no_encoding_ascii, @@ -699,10 +704,18 @@ #endif } +static void +mbstring_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC) +{ +#if HAVE_MBREGEX + zend_hash_destroy(&MBSTRG(ht_rc)); +#endif +} + PHP_MINIT_FUNCTION(mbstring) { #ifdef ZTS - ts_allocate_id(&mbstring_globals_id, sizeof(zend_mbstring_globals), (ts_allocate_ctor) php_mbstring_init_globals, NULL); + ts_allocate_id(&mbstring_globals_id, sizeof(zend_mbstring_globals), (ts_allocate_ctor) php_mbstring_init_globals, (ts_allocate_dtor) mbstring_globals_dtor); #else php_mbstring_init_globals(&mbstring_globals TSRMLS_CC); #endif @@ -723,6 +736,12 @@ REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT); + +#if HAVE_MBREGEX +# ifdef ZTS + mbregex_locale_mutex = tsrm_mutex_alloc(); +# endif +#endif return SUCCESS; } @@ -748,7 +767,17 @@ } #if HAVE_MBREGEX - zend_hash_destroy(&MBSTRG(ht_rc)); +# ifdef ZTS + if (mbregex_locale_mutex != NULL) { + tsrm_mutex_free(mbregex_locale_mutex); + } +# endif +#endif + +#ifdef ZTS + ts_free_id(mbstring_globals_id); +#else + mbstring_globals_dtor(&mbstring_globals TSRMLS_CC); #endif return SUCCESS;

« previous php.cvs (#14718) next »