[PHP-CVS] cvs: php4 /sapi/caudium caudium.c
neotron Mon Apr 23 18:08:35 2001 EDT Modified files: /php4/sapi/caudium caudium.c Log: Disable use of th_farm since it doesn't seem to work. Uses a Pike layer thread farm now instead. Index: php4/sapi/caudium/caudium.c diff -u php4/sapi/caudium/caudium.c:1.10 php4/sapi/caudium/caudium.c:1.11 --- php4/sapi/caudium/caudium.c:1.10Sun Feb 25 22:07:36 2001 +++ php4/sapi/caudium/caudium.c Mon Apr 23 18:08:35 2001 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: caudium.c,v 1.10 2001/02/26 06:07:36 andi Exp $ */ +/* $Id: caudium.c,v 1.11 2001/04/24 01:08:35 neotron Exp $ */ #include "php.h" #ifdef HAVE_CAUDIUM @@ -37,10 +37,13 @@ * */ #define NO_PIKE_SHORTHAND -/* Define to run w/o th_farm. This allows for A LOT easier - * debugging due to stupid gdb... + +/* Ok, we are now using Pike level threads to handle PHP4 since + * the nice th_farm threads aren't working on Linux with glibc 2.2 + * (why this is I don't know). */ -/*#define TEST_NO_THREADS*/ +#define USE_PIKE_LEVEL_THREADS + #include #include #include @@ -439,7 +442,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.10 2001/02/26 06:07:36 andi Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.11 +2001/04/24 01:08:35 neotron Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -553,10 +556,11 @@ static void php_caudium_module_main(php_caudium_request *ureq) { int res; - int cnt = 0; zend_file_handle file_handle; +#ifndef USE_PIKE_LEVEL_THREADS struct thread_state *state; extern struct program *thread_id_prog; +#endif SLS_FETCH(); CLS_FETCH(); PLS_FETCH(); @@ -569,30 +573,32 @@ THIS->request_data = ureq->request_data; free(ureq); -#ifndef TEST_NO_THREADS +#ifndef USE_PIKE_LEVEL_THREADS mt_lock_interpreter(); init_interpreter(); #if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1 + thread_id = low_clone(thread_id_prog); + state = OBJ2THREAD(thread_id); Pike_stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION; recoveries = NULL; - thread_id = low_clone(thread_id_prog); call_c_initializers(thread_id); - SWAP_OUT_THREAD(OBJ2THREAD(thread_id)); - OBJ2THREAD(thread_id)->swapped=0; OBJ2THREAD(thread_id)->id=th_self(); num_threads++; thread_table_insert(thread_id); + state->status=THREAD_RUNNING; #else + Pike_interpreter.thread_id = low_clone(thread_id_prog); + state = OBJ2THREAD(Pike_interpreter.thread_id); Pike_interpreter.stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION; Pike_interpreter.recoveries = NULL; - Pike_interpreter.thread_id = low_clone(thread_id_prog); call_c_initializers(Pike_interpreter.thread_id); - SWAP_OUT_THREAD(OBJ2THREAD(Pike_interpreter.thread_id)); - OBJ2THREAD(Pike_interpreter.thread_id)->swapped=0; - OBJ2THREAD(Pike_interpreter.thread_id)->id=th_self(); + state->id=th_self(); + // SWAP_OUT_THREAD(OBJ2THREAD(Pike_interpreter.thread_id)); num_threads++; thread_table_insert(Pike_interpreter.thread_id); + state->status=THREAD_RUNNING; #endif + state->swapped = 0; #endif SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0); SG(server_context) = (void *)1; /* avoid server_context == NULL */ @@ -621,9 +627,11 @@ * Pike threads to run. We wait since the above would otherwise require * a lot of unlock/lock. */ -#ifndef TEST_NO_THREADS - SWAP_OUT_CURRENT_THREAD(); +#ifndef USE_PIKE_LEVEL_THREADS + SWAP_OUT_THREAD(state); mt_unlock_interpreter(); +#else + THREADS_ALLOW(); #endif #ifdef VIRTUAL_DIR @@ -637,13 +645,14 @@ file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = THIS->filename->str; + file_handle.opened_path = NULL; file_handle.free_filename = 0; + THIS->written = 0; res = php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); if(res == FAILURE) { THREAD_SAFE_RUN({ - apply_svalue(&THIS->done_cb, 0); pop_stack(); free_struct(SLS_C); @@ -660,18 +669,19 @@ free_struct(SLS_C); }, "positive run response"); } -#ifndef TEST_NO_THREADS + +#ifndef USE_PIKE_LEVEL_THREADS mt_lock_interpreter(); - SWAP_IN_CURRENT_THREAD(); + SWAP_IN_THREAD(state); #if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1 - OBJ2THREAD(thread_id)->status=THREAD_EXITED; - co_signal(& OBJ2THREAD(thread_id)->status_change); + state->status=THREAD_EXITED; + co_signal(& state->status_change); thread_table_delete(thread_id); free_object(thread_id); thread_id=NULL; #else - OBJ2THREAD(Pike_interpreter.thread_id)->status=THREAD_EXITED; - co_signal(& OBJ2THREAD(Pike_interpreter.thread_id)
[PHP-CVS] cvs: php4 /sapi/caudium caudium.c
neotron Thu Feb 8 21:32:42 2001 EDT Modified files: /php4/sapi/caudium caudium.c Log: Fixed PHP authentication and some other minor things. Index: php4/sapi/caudium/caudium.c diff -u php4/sapi/caudium/caudium.c:1.8 php4/sapi/caudium/caudium.c:1.9 --- php4/sapi/caudium/caudium.c:1.8 Tue Jan 2 14:49:28 2001 +++ php4/sapi/caudium/caudium.c Thu Feb 8 21:32:42 2001 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $ */ +/* $Id: caudium.c,v 1.9 2001/02/09 05:32:42 neotron Exp $ */ #include "php.h" #ifdef HAVE_CAUDIUM @@ -121,26 +121,15 @@ */ #define REQUEST_DATA ((struct mapping *)(THIS->request_data)) - -#if 0 && defined(_REENTRANT) && !defined(CAUDIUM_USE_ZTS) -/* Lock used to serialize the PHP execution. If CAUDIUM_USE_ZTS is defined, we - * are using the PHP thread safe mechanism instead. - */ -static PIKE_MUTEX_T caudium_php_execution_lock; -# define PHP_INIT_LOCK() mt_init(&caudium_php_execution_lock) -# define PHP_LOCK(X) THREADS_ALLOW();mt_lock(&caudium_php_execution_lock);THREADS_DISALLOW() -# define PHP_UNLOCK(X) mt_unlock(&caudium_php_execution_lock); -# define PHP_DESTROY() mt_destroy(&caudium_php_execution_lock) -#else /* !_REENTRANT */ -# define PHP_INIT_LOCK() -# define PHP_LOCK(X) -# define PHP_UNLOCK(X) -# define PHP_DESTROY() -#endif /* _REENTRANT */ - extern int fd_from_object(struct object *o); static unsigned char caudium_php_initialized; +#ifndef mt_lock_interpreter +#define mt_lock_interpreter() mt_lock(&interpreter_lock); +#define mt_unlock_interpreter() mt_unlock(&interpreter_lock); +#endif + + /* This allows calling of pike functions from the PHP callbacks, * which requires the Pike interpreter to be locked. */ @@ -150,25 +139,17 @@ if(!state->swapped) {\ COMMAND;\ } else {\ - mt_lock(&interpreter_lock);\ + mt_lock_interpreter();\ SWAP_IN_THREAD(state);\ COMMAND;\ SWAP_OUT_THREAD(state);\ - mt_unlock(&interpreter_lock);\ + mt_unlock_interpreter();\ }\ }\ } while(0) -struct program *php_program; -/* To avoid executing a PHP script from a PHP callback, which would - * create a deadlock, a global thread id is used. If the thread calling the - * php-script is the same as the current thread, it fails. - */ -//static int current_thread = -1; - - /* Low level header lookup. Basically looks for the named header in the mapping * headers in the supplied options mapping. */ @@ -458,7 +439,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.9 2001/02/09 +05:32:42 neotron Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -571,27 +552,25 @@ static void php_caudium_module_main(php_caudium_request *ureq) { - int res, len; - char *dir; + int res; + int cnt = 0; zend_file_handle file_handle; struct thread_state *state; extern struct program *thread_id_prog; - // struct php_caudium_request *ureq; SLS_FETCH(); CLS_FETCH(); PLS_FETCH(); ELS_FETCH(); GET_THIS(); - // ureq = (struct php_caudium_request *)ud; THIS->filename = ureq->filename; THIS->done_cb = ureq->done_cb; THIS->my_fd_obj = ureq->my_fd_obj; THIS->my_fd = ureq->my_fd; THIS->request_data = ureq->request_data; free(ureq); - // current_thread = th_self(); + #ifndef TEST_NO_THREADS - mt_lock(&interpreter_lock); + mt_lock_interpreter(); init_interpreter(); #if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1 Pike_stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION; @@ -636,25 +615,22 @@ SG(request_info).headers_only = 0; } - /* FIXME: Check for auth stuff needs to be fixed... */ - SG(request_info).auth_user = NULL; - SG(request_info).auth_password = NULL; - - /* Swap out this thread and release the interpreter lock to allow + /* Let PHP4 handle the deconding of the AUTH */ + php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), SLS_C); + /* Swap out this thread and release the interpreter lock to allow * Pike threads to run. We wait since the above would otherwise require * a lot of unlock/lock. */ #ifndef TEST_NO_THREADS SWAP_OUT_CURRENT_THREAD(); - mt_unlock(&interpreter_lock); + mt_unlock_interpreter(); #endif - /* Change virtual work directory */ - #ifdef VIRTUAL_DIR /* Change virtual directory, if the feature is enabled, which is - * almost a requirement for PHP in Roxen. Might want to fail if it - * isn't. Not a problem though, since it's on by defa