ZTS fixes

This commit is contained in:
Moriyoshi Koizumi 2002-10-08 17:20:10 +00:00
parent 03777770c0
commit 579a1c3ab1
2 changed files with 41 additions and 2 deletions

View File

@ -306,9 +306,16 @@ init_syntax_once()
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 @@ init_syntax_once()
re_syntax_table[c] = Sword2;
}
}
#ifdef ZTS
tsrm_mutex_unlock( mbregex_locale_mutex );
#endif
done = 1;
}

View File

@ -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 @@ php_mbstring_init_globals(zend_mbstring_globals *pglobals TSRMLS_DC)
#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 @@ PHP_MINIT_FUNCTION(mbstring)
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 @@ PHP_MSHUTDOWN_FUNCTION(mbstring)
}
#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;