cvs: pecl /chasen php_chasen.c

From: Date: Sun, 10 Aug 2003 12:45:11 +0000
Subject: cvs: pecl /chasen php_chasen.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-416@lists.php.net to get a copy of this message
moriyoshi Sun Aug 10 08:45:11 2003 EDT Modified files: /pecl/chasen php_chasen.c Log: Fix segfault. No need to nullify mtx after unlocking. Index: pecl/chasen/php_chasen.c diff -u pecl/chasen/php_chasen.c:1.2 pecl/chasen/php_chasen.c:1.3 --- pecl/chasen/php_chasen.c:1.2 Sun Aug 10 04:47:26 2003 +++ pecl/chasen/php_chasen.c Sun Aug 10 08:45:11 2003 @@ -14,7 +14,7 @@ 2001.12.3 Release 0.3.0 */ -/* $Id: php_chasen.c,v 1.2 2003/08/10 08:47:26 moriyoshi Exp $ */ +/* $Id: php_chasen.c,v 1.3 2003/08/10 12:45:11 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -32,16 +32,7 @@ #if HAVE_CHASEN #ifdef ZTS -static MUTEX_T php_chasen_lock_id = NULL; -#define php_chasen_lock() tsrm_mutex_lock(php_chasen_lock_id) -#define php_chasen_unlock() { tsrm_mutex_unlock(php_chasen_lock_id); php_chasen_lock_id = NULL; } -#define php_chasen_lock_init() php_chasen_lock_id = tsrm_mutex_alloc() -#define php_chasen_lock_destroy() tsrm_mutex_free(php_chasen_lock_id) -#else -#define php_chasen_lock() -#define php_chasen_unlock() -#define php_chasen_lock_init() -#define php_chasen_lock_destroy() +static MUTEX_T php_chasen_mtx; #endif static char *php_chasen_command = "chasen"; @@ -75,7 +66,9 @@ PHP_MINIT_FUNCTION(chasen) { #ifdef ZTS - php_chasen_lock_init(); + if ((php_chasen_mtx = tsrm_mutex_alloc()) == NULL) { + return FAILURE; + } #endif return SUCCESS; } @@ -83,7 +76,8 @@ PHP_MSHUTDOWN_FUNCTION(chasen) { #ifdef ZTS - php_chasen_lock_destroy(); + tsrm_mutex_free(php_chasen_mtx); + php_chasen_mtx = NULL; #endif return SUCCESS; } @@ -128,9 +122,10 @@ break; } - php_chasen_lock(); + tsrm_mutex_lock(php_chasen_mtx); + if (chasen_getopt_argv(argv, NULL) != 0) { - php_chasen_unlock(); + tsrm_mutex_unlock(php_chasen_mtx); if (argv) { efree(argv); } @@ -145,7 +140,7 @@ } else { RETVAL_STRINGL(empty_string, 0, 1); } - php_chasen_unlock(); + tsrm_mutex_unlock(php_chasen_mtx); if (argv) { efree(argv); @@ -167,10 +162,12 @@ } convert_to_string_ex(arg_str); - php_chasen_lock(); + + tsrm_mutex_lock(php_chasen_mtx); + if (chasen_getopt_argv(php_chasen_argv_wakati, NULL) != 0) { php_error(E_WARNING,"unable to initialize chasen library"); - php_chasen_unlock(); + tsrm_mutex_unlock(php_chasen_mtx); RETURN_FALSE; } res = chasen_sparse_tostr(Z_STRVAL_PP(arg_str)); @@ -194,7 +191,7 @@ } else { RETVAL_FALSE; } - php_chasen_unlock(); + tsrm_mutex_unlock(php_chasen_mtx); } /* }}} */

« previous php.pecl.cvs (#416) next »