diff options
| author | Jason Greene <jason@php.net> | 2001-07-30 19:40:29 +0000 | 
|---|---|---|
| committer | Jason Greene <jason@php.net> | 2001-07-30 19:40:29 +0000 | 
| commit | 40c7f095097df14bf55207220c98b2c6cb6f272c (patch) | |
| tree | f857dcc60944fb621c9510d4595e2bd1ebe84fde | |
| parent | 3b7bc2535abea052548fe7635f2c3ec530af4ae7 (diff) | |
| download | php-git-40c7f095097df14bf55207220c98b2c6cb6f272c.tar.gz | |
Fully implement new thread safe model.
Fix ws.
| -rwxr-xr-x | ext/pcntl/pcntl.c | 45 | ||||
| -rw-r--r-- | ext/pcntl/php_pcntl.h | 7 | 
2 files changed, 31 insertions, 21 deletions
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 23b771e697..890f20c071 100755 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -151,32 +151,44 @@ void php_register_signal_constants(INIT_FUNC_ARGS)  	REGISTER_LONG_CONSTANT("SIGSYS",   (long) SIGSYS, CONST_CS | CONST_PERSISTENT);  } -PHP_MINIT_FUNCTION(pcntl) +static void php_pcntl_init_globals(zend_pcntl_globals *pcntl_globals)   { - 	PCNTL_LS_FETCH(); - -   	php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU); -	zend_hash_init(&PCNTL_G(php_signal_table), 16, NULL, NULL, 1); +	zend_hash_init(&pcntl_globals->php_signal_table, 16, NULL, NULL, 1);  	/* Just in case ... */ -	memset(&PCNTL_G(php_signal_queue),0,sizeof(PCNTL_G(php_signal_queue))); +	memset(&pcntl_globals->php_signal_queue,0,sizeof(pcntl_globals->php_signal_queue)); -	zend_llist_init(&PCNTL_G(php_signal_queue), sizeof (long),  NULL, 1); -	PCNTL_G(signal_queue_ready)=0; -	PCNTL_G(processing_signal_queue)=0; +	zend_llist_init(&pcntl_globals->php_signal_queue, sizeof (long),  NULL, 1); +	pcntl_globals->signal_queue_ready=0; +	pcntl_globals->processing_signal_queue=0; +} + +static void php_pcntl_shutdown_globals(zend_pcntl_globals *pcntl_globals)  +{ +	zend_hash_destroy(&pcntl_globals->php_signal_table); +	zend_llist_destroy(&pcntl_globals->php_signal_queue); +} + +PHP_MINIT_FUNCTION(pcntl) +{ +   	php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU); +	ZEND_INIT_MODULE_GLOBALS(pcntl, php_pcntl_init_globals, php_pcntl_shutdown_globals);  	if (zend_register_extension(&pcntl_extension_entry, 0)==FAILURE)   		return FAILURE;  	return SUCCESS;  } +  PHP_MSHUTDOWN_FUNCTION(pcntl)  { -	PCNTL_LS_FETCH(); -    +  	zend_hash_destroy(&PCNTL_G(php_signal_table));  	zend_llist_destroy(&PCNTL_G(php_signal_queue));  	return SUCCESS;  } + + +  PHP_MINFO_FUNCTION(pcntl)  {  	php_info_print_table_start(); @@ -355,7 +367,6 @@ PHP_FUNCTION(pcntl_signal)  {  	zval **signo, **handle;     	char *func_name; -	PCNTL_LS_FETCH();  	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &signo, &handle) == FAILURE) {  		WRONG_PARAM_COUNT; @@ -404,10 +415,9 @@ static void old_pcntl_signal_handler(int signo)  {  	char *func_name;  	zval *param, *call_name, *retval; -  	PCNTL_LS_FETCH();  	TSRMLS_FETCH(); -    DEBUG_OUT("Caught signal: %d\n", signo);  +	DEBUG_OUT("Caught signal: %d\n", signo);   	if (zend_hash_index_find(&PCNTL_G(php_signal_table), (long) signo, (void *) &func_name)==FAILURE) {  		DEBUG_OUT("Signl handler not fount");   		return; @@ -434,7 +444,7 @@ static void old_pcntl_signal_handler(int signo)  static void pcntl_signal_handler(int signo)  {  	long signal_num=signo; -	PCNTL_LS_FETCH(); +	TSRMLS_FETCH();  	DEBUG_OUT("Caught signo %d\n", signo);   	if (! PCNTL_G(processing_signal_queue) && pcntl_zend_extension_active ) { @@ -450,6 +460,8 @@ static void pcntl_signal_handler(int signo)  int pcntl_zend_extension_startup(zend_extension *extension)  { +	TSRMLS_FETCH(); +     	DEBUG_OUT("Statup Called\n");  	pcntl_zend_extension_active=1;  	CG(extended_info) = 1; @@ -464,6 +476,8 @@ void pcntl_zend_extension_shutdown(zend_extension *extension)  void pcntl_zend_extension_activate(void)  { +	TSRMLS_FETCH(); +     	DEBUG_OUT("Activate Called\n");  	pcntl_zend_extension_active=1;  	CG(extended_info) = 1; @@ -483,7 +497,6 @@ void pcntl_zend_extension_statement_handler(zend_op_array *op_array)  	zend_llist_element *element;      zval *param, *call_name, *retval;  	char *func_name; -	PCNTL_LS_FETCH();  	TSRMLS_FETCH();  	/* Bail if the queue is empty or if we are already playing the queue*/ diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h index 347c77f275..7154dcd4de 100644 --- a/ext/pcntl/php_pcntl.h +++ b/ext/pcntl/php_pcntl.h @@ -63,13 +63,10 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)  	int signal_queue_ready;  	int processing_signal_queue;  ZEND_END_MODULE_GLOBALS(pcntl) -  #ifdef ZTS -#define PCNTL_G(v) (pcntl_globals->v) -#define PCNTL_LS_FETCH() zend_pcntl_globals *pcntl_globals = ts_resource(pcntl_globals_id) +# define PCNTL_G(v) TSRMG(pcntl_globals_id, zend_pcntl_globals *, v)  #else -#define PCNTL_G(v) (pcntl_globals.v) -#define PCNTL_LS_FETCH() +# define PCNTL_G(v)	(pcntl_globals.v)  #endif  #endif	/* PHP_PCNTL_H */  | 
