X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=apc_main.c;h=3825399a906d34596344724f56b1d649d02bd3f6;hb=refs%2Fheads%2Forigin;hp=50b673d7504ad7705114beac95ce6992413efdfb;hpb=27531cfcd6e8fb46402c6771ef4c2d97233917af;p=php5-apc.git diff --git a/apc_main.c b/apc_main.c index 50b673d..3825399 100644 --- a/apc_main.c +++ b/apc_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | APC | +----------------------------------------------------------------------+ - | Copyright (c) 2006 The PHP Group | + | Copyright (c) 2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -28,7 +28,7 @@ */ -/* $Id: apc_main.c,v 3.103 2007/11/14 19:46:46 shire Exp $ */ +/* $Id: apc_main.c,v 3.103.2.7 2008/05/11 18:57:00 rasmus Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -71,14 +71,20 @@ static zend_compile_t* set_compile_hook(zend_compile_t *ptr) /* {{{ install_function */ static int install_function(apc_function_t fn TSRMLS_DC) { - int status = - zend_hash_add(EG(function_table), + zend_function *func; + int status; + + func = apc_copy_function_for_execution(fn.function); + + status = zend_hash_add(EG(function_table), fn.name, fn.name_len+1, - apc_copy_function_for_execution(fn.function), + func, sizeof(fn.function[0]), NULL); + efree(func); + if (status == FAILURE) { /* apc_eprint("Cannot redeclare %s()", fn.name); */ } @@ -273,9 +279,9 @@ default_compile: apc_cache_release(apc_cache, cache_entry); /* cannot free up cache data yet, it maybe in use */ - - zend_llist_del_element(&CG(open_files), h, compare_file_handles); /* XXX: kludge */ - + + zend_llist_del_element(&CG(open_files), h, compare_file_handles); /* We leak fds without this hack */ + h->type = ZEND_HANDLE_FILENAME; return NULL; @@ -298,9 +304,9 @@ static zend_op_array* my_compile_file(zend_file_handle* h, char *path; size_t mem_size; - if (!APCG(enabled) || (apc_cache_busy(apc_cache) && !APCG(localcache))) { - return old_compile_file(h, type TSRMLS_CC); - } + if (!APCG(enabled) || apc_cache_busy(apc_cache)) { + return old_compile_file(h, type TSRMLS_CC); + } /* check our regular expression filters */ if (APCG(filters) && apc_compiled_filters) { @@ -333,13 +339,8 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if(!APCG(force_file_update)) { - if(APCG(localcache)) { - /* search for the file in the local cache */ - cache_entry = apc_local_cache_find(APCG(lcache), key, t); - } else { - /* search for the file in the cache */ - cache_entry = apc_cache_find(apc_cache, key, t); - } + /* search for the file in the cache */ + cache_entry = apc_cache_find(apc_cache, key, t); } else { cache_entry = NULL; } @@ -350,7 +351,9 @@ static zend_op_array* my_compile_file(zend_file_handle* h, h->opened_path = estrdup(cache_entry->data.file.filename); } zend_hash_add(&EG(included_files), h->opened_path, strlen(h->opened_path)+1, (void *)&dummy, sizeof(int), NULL); - zend_llist_add_element(&CG(open_files), h); /* XXX kludge */ + + zend_llist_add_element(&CG(open_files), h); /* We leak fds without this hack */ + apc_stack_push(APCG(cache_stack), cache_entry); op_array = cached_compile(h, type TSRMLS_CC); if(op_array) { @@ -366,11 +369,6 @@ static zend_op_array* my_compile_file(zend_file_handle* h, /* TODO: check what happens with EG(included_files) */ } - if(apc_cache_busy(apc_cache) && APCG(localcache)) { - /* possibly local cache returned NULL because cache is busy */ - return old_compile_file(h, type TSRMLS_CC); - } - /* remember how many functions and classes existed before compilation */ num_functions = zend_hash_num_elements(CG(function_table)); num_classes = zend_hash_num_elements(CG(class_table)); @@ -407,7 +405,7 @@ static zend_op_array* my_compile_file(zend_file_handle* h, tmp_buf = sapi_get_stat(TSRMLS_C); /* Apache has already done this stat() for us */ } if(tmp_buf) { - fileinfo.st_buf = *tmp_buf; + fileinfo.st_buf.sb = *tmp_buf; } else { if (apc_search_paths(h->filename, PG(include_path), &fileinfo) != 0) { #ifdef __DEBUG_APC__ @@ -416,7 +414,7 @@ static zend_op_array* my_compile_file(zend_file_handle* h, return op_array; } } - key.mtime = fileinfo.st_buf.st_mtime; + key.mtime = fileinfo.st_buf.sb.st_mtime; } HANDLE_BLOCK_INTERRUPTIONS(); @@ -592,56 +590,17 @@ int apc_module_shutdown(TSRMLS_D) /* {{{ process init and shutdown */ int apc_process_init(int module_number TSRMLS_DC) { - int minttl = (APCG(gc_ttl) > APCG(ttl) ? APCG(ttl) : APCG(gc_ttl))/2; - int size = APCG(localcache_size); - if(APCG(initialized) && APCG(localcache)) { - /* TTL is 2 mins by default */ - APCG(lcache) = apc_local_cache_create(apc_cache, size, minttl ? minttl : 120); - } return 0; } int apc_process_shutdown(TSRMLS_D) { - if(APCG(initialized) && APCG(localcache) && APCG(lcache)) { - apc_local_cache_destroy(APCG(lcache)); - APCG(lcache) = NULL; - } - return 0; -} -/* }}} */ - -/* {{{ request init and shutdown */ - -int apc_request_init(TSRMLS_D) -{ - apc_stack_clear(APCG(cache_stack)); - APCG(slam_rand) = -1; - APCG(copied_zvals) = NULL; - -#ifdef APC_FILEHITS - ALLOC_INIT_ZVAL(APCG(filehits)); - array_init(APCG(filehits)); -#endif - - return 0; -} - -int apc_request_shutdown(TSRMLS_D) -{ - apc_deactivate(TSRMLS_C); - -#ifdef APC_FILEHITS - zval_ptr_dtor(&APCG(filehits)); -#endif - return 0; } - /* }}} */ /* {{{ apc_deactivate */ -void apc_deactivate(TSRMLS_D) +static void apc_deactivate(TSRMLS_D) { /* The execution stack was unwound, which prevented us from decrementing * the reference counts on active cache entries in `my_execute`. @@ -685,12 +644,40 @@ void apc_deactivate(TSRMLS_D) } apc_cache_release(apc_cache, cache_entry); } - if(APCG(localcache)) { - apc_local_cache_cleanup(APCG(lcache)); - } + +} +/* }}} */ + +/* {{{ request init and shutdown */ + +int apc_request_init(TSRMLS_D) +{ + apc_stack_clear(APCG(cache_stack)); + APCG(slam_rand) = -1; + APCG(copied_zvals) = NULL; + +#ifdef APC_FILEHITS + ALLOC_INIT_ZVAL(APCG(filehits)); + array_init(APCG(filehits)); +#endif + + return 0; } + +int apc_request_shutdown(TSRMLS_D) +{ + apc_deactivate(TSRMLS_C); + +#ifdef APC_FILEHITS + zval_ptr_dtor(&APCG(filehits)); +#endif + + return 0; +} + /* }}} */ + /* * Local variables: * tab-width: 4