cvs: pecl /apc CHANGELOG apc_compile.c apc_globals.h apc_main.c php_apc.c

From: Date: Mon, 24 Mar 2008 01:01:26 +0000
Subject: cvs: pecl /apc CHANGELOG apc_compile.c apc_globals.h apc_main.c php_apc.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-10041@lists.php.net to get a copy of this message
shire Mon Mar 24 01:01:26 2008 UTC Modified files: /pecl/apc CHANGELOG apc_compile.c apc_globals.h apc_main.c php_apc.c Log: fix misc memleaks: added refcount stack to free refcounts, memleak in opened_path, and allocation in install_function http://cvs.php.net/viewvc.cgi/pecl/apc/CHANGELOG?r1=1.41&r2=1.42&diff_format=u Index: pecl/apc/CHANGELOG diff -u pecl/apc/CHANGELOG:1.41 pecl/apc/CHANGELOG:1.42 --- pecl/apc/CHANGELOG:1.41 Fri Feb 22 07:43:13 2008 +++ pecl/apc/CHANGELOG Mon Mar 24 01:01:25 2008 @@ -1,5 +1,6 @@ - Fix apc_add() cache expunge bug (Rasmus) - Added parameter to apc_fetch to determine success/failure when fetching booleans (shire) +- Fix misc. memleaks (shire) 3.0.16: 2007-12-26 - Fix for longstanding cache-full crash (Christian Seiler) http://cvs.php.net/viewvc.cgi/pecl/apc/apc_compile.c?r1=3.90&r2=3.91&diff_format=u Index: pecl/apc/apc_compile.c diff -u pecl/apc/apc_compile.c:3.90 pecl/apc/apc_compile.c:3.91 --- pecl/apc/apc_compile.c:3.90 Thu Jan 31 06:20:00 2008 +++ pecl/apc/apc_compile.c Mon Mar 24 01:01:25 2008 @@ -28,7 +28,7 @@ */ -/* $Id: apc_compile.c,v 3.90 2008/01/31 06:20:00 gopalv Exp $ */ +/* $Id: apc_compile.c,v 3.91 2008/03/24 01:01:25 shire Exp $ */ #include "apc_compile.h" #include "apc_globals.h" @@ -1971,6 +1971,8 @@ dst->refcount = apc_xmemcpy(src->refcount, sizeof(src->refcount[0]), apc_php_malloc); + + apc_stack_push(APCG(refcount_stack), (void*)dst->refcount); my_prepare_op_array_for_execution(dst,src TSRMLS_CC); http://cvs.php.net/viewvc.cgi/pecl/apc/apc_globals.h?r1=3.74&r2=3.75&diff_format=u Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.74 pecl/apc/apc_globals.h:3.75 --- pecl/apc/apc_globals.h:3.74 Tue Jan 29 21:57:44 2008 +++ pecl/apc/apc_globals.h Mon Mar 24 01:01:25 2008 @@ -29,7 +29,7 @@ */ -/* $Id: apc_globals.h,v 3.74 2008/01/29 21:57:44 shire Exp $ */ +/* $Id: apc_globals.h,v 3.75 2008/03/24 01:01:25 shire Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -58,6 +58,7 @@ /* module variables */ zend_bool initialized; /* true if module was initialized */ apc_stack_t* cache_stack; /* the stack of cached executable code */ + apc_stack_t* refcount_stack; /* the stack of refcounts to be free'd in request shutdown */ zend_bool cache_by_default; /* true if files should be cached unless filtered out */ /* false if files should only be cached if filtered in */ long slam_defense; /* Probability of a process not caching an uncached file */ http://cvs.php.net/viewvc.cgi/pecl/apc/apc_main.c?r1=3.108&r2=3.109&diff_format=u Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.108 pecl/apc/apc_main.c:3.109 --- pecl/apc/apc_main.c:3.108 Wed Jan 30 01:58:13 2008 +++ pecl/apc/apc_main.c Mon Mar 24 01:01:25 2008 @@ -28,7 +28,7 @@ */ -/* $Id: apc_main.c,v 3.108 2008/01/30 01:58:13 shire Exp $ */ +/* $Id: apc_main.c,v 3.109 2008/03/24 01:01:25 shire Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -71,14 +71,20 @@ /* {{{ 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); */ } @@ -307,8 +313,10 @@ if (cache_entry != NULL) { int dummy = 1; + int reset_opened_path = 0; if (h->opened_path == NULL) { - h->opened_path = estrdup(cache_entry->data.file.filename); + h->opened_path = cache_entry->data.file.filename; + reset_opened_path = 1; } zend_hash_add(&EG(included_files), h->opened_path, strlen(h->opened_path)+1, (void *)&dummy, sizeof(int), NULL); apc_stack_push(APCG(cache_stack), cache_entry); @@ -323,6 +331,9 @@ 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) */ } @@ -583,6 +594,7 @@ /* {{{ apc_deactivate */ void apc_deactivate(TSRMLS_D) { + zend_uint *refcount_p; /* The execution stack was unwound, which prevented us from decrementing * the reference counts on active cache entries in my_execute. */ @@ -596,6 +608,11 @@ (apc_cache_entry_t*) apc_stack_pop(APCG(cache_stack)); if (cache_entry->data.file.classes) { + for (i = 0; cache_entry->data.file.functions[i].function != NULL; i++) { + zend_hash_del(EG(function_table), + cache_entry->data.file.functions[i].name, + cache_entry->data.file.functions[i].name_len+1); + } for (i = 0; cache_entry->data.file.classes[i].class_entry != NULL; i++) { centry = (void**)&pzce; /* a triple indirection to get zend_class_entry*** */ if(zend_hash_find(EG(class_table), @@ -619,6 +636,13 @@ } apc_cache_release(apc_cache, cache_entry); } + + /* prevent memleak warnings on refcounts that have been alloc'd */ + while (apc_stack_size(APCG(refcount_stack)) > 0) { + refcount_p = (zend_uint*)apc_stack_pop(APCG(refcount_stack)); + efree(refcount_p); + } + } /* }}} */ http://cvs.php.net/viewvc.cgi/pecl/apc/php_apc.c?r1=3.164&r2=3.165&diff_format=u Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.164 pecl/apc/php_apc.c:3.165 --- pecl/apc/php_apc.c:3.164 Sat Mar 8 01:37:19 2008 +++ pecl/apc/php_apc.c Mon Mar 24 01:01:25 2008 @@ -26,7 +26,7 @@ */ -/* $Id: php_apc.c,v 3.164 2008/03/08 01:37:19 shire Exp $ */ +/* $Id: php_apc.c,v 3.165 2008/03/24 01:01:25 shire Exp $ */ #include "apc_zend.h" #include "apc_cache.h" @@ -78,6 +78,7 @@ apc_globals->filters = NULL; apc_globals->initialized = 0; apc_globals->cache_stack = apc_stack_create(0); + apc_globals->refcount_stack = apc_stack_create(0); apc_globals->cache_by_default = 1; apc_globals->slam_defense = 0; apc_globals->mem_size_ptr = NULL; @@ -222,7 +223,7 @@ #else php_info_print_table_row(2, "Locking type", "File Locks"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.164 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.165 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); php_info_print_table_end(); DISPLAY_INI_ENTRIES();

« previous php.pecl.cvs (#10041) next »