+----------------------------------------------------------------------+
| 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 |
*/
-/* $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"
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;
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) {
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) */
}
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);
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);
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);
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);
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);