X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=php5-apc.git;a=blobdiff_plain;f=apc_main.c;h=3825399a906d34596344724f56b1d649d02bd3f6;hp=3cfb279216216c50fa293e2547fdd34b72a19032;hb=10aea07a14325aa0bfb5fe75ddcf19432c6e2c64;hpb=3682e0a7a26931aabca2b6e54eb08efd7dc0430b diff --git a/apc_main.c b/apc_main.c index 3cfb279..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.2.2 2008/03/28 18:35:40 gopalv 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" @@ -279,7 +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); /* We leak fds without this hack */ + h->type = ZEND_HANDLE_FILENAME; return NULL; @@ -345,12 +347,13 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if (cache_entry != NULL) { int dummy = 1; - int reset_opened_path = 0; if (h->opened_path == NULL) { - h->opened_path = cache_entry->data.file.filename; - reset_opened_path = 1; + 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); /* 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) { @@ -363,9 +366,6 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if(APCG(report_autofilter)) { apc_wprint("Recompiling %s", h->opened_path); } - if (reset_opened_path == 1) { - h->opened_path = NULL; - } /* TODO: check what happens with EG(included_files) */ } @@ -430,10 +430,10 @@ static zend_op_array* my_compile_file(zend_file_handle* h, mem_size = 0; APCG(mem_size_ptr) = &mem_size; - APCG(current_cache) = apc_cache; if(!(alloc_op_array = apc_copy_op_array(NULL, op_array, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; #if NONBLOCKING_LOCK_AVAILABLE if(APCG(write_lock)) { apc_cache_write_unlock(apc_cache); @@ -445,8 +445,9 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if(!(alloc_functions = apc_copy_new_functions(num_functions, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_free_op_array(alloc_op_array, apc_sma_free); + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; #if NONBLOCKING_LOCK_AVAILABLE if(APCG(write_lock)) { apc_cache_write_unlock(apc_cache); @@ -458,8 +459,9 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if(!(alloc_classes = apc_copy_new_classes(op_array, num_classes, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_free_op_array(alloc_op_array, apc_sma_free); apc_free_functions(alloc_functions, apc_sma_free); + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; #if NONBLOCKING_LOCK_AVAILABLE if(APCG(write_lock)) { apc_cache_write_unlock(apc_cache); @@ -480,8 +482,9 @@ static zend_op_array* my_compile_file(zend_file_handle* h, apc_free_op_array(alloc_op_array, apc_sma_free); apc_free_functions(alloc_functions, apc_sma_free); apc_free_classes(alloc_classes, apc_sma_free); + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; #if NONBLOCKING_LOCK_AVAILABLE if(APCG(write_lock)) { apc_cache_write_unlock(apc_cache); @@ -495,10 +498,12 @@ static zend_op_array* my_compile_file(zend_file_handle* h, if ((ret = apc_cache_insert(apc_cache, key, cache_entry, t)) != 1) { apc_cache_free_entry(cache_entry); + if(ret==-1) { + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); + } } - APCG(current_cache) = NULL; - #if NONBLOCKING_LOCK_AVAILABLE if(APCG(write_lock)) { apc_cache_write_unlock(apc_cache);