cvs: pecl(APC_3_0) /apc CHANGELOG apc_cache.c apc_cache.h apc_globals.h apc_main.c apc_sma.c php_apc.c

From: Date: Sat, 29 Mar 2008 06:38:40 +0000
Subject: cvs: pecl(APC_3_0) /apc CHANGELOG apc_cache.c apc_cache.h apc_globals.h apc_main.c apc_sma.c php_apc.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-10104@lists.php.net to get a copy of this message
rasmus Sat Mar 29 06:38:40 2008 UTC Modified files: (Branch: APC_3_0) /pecl/apc CHANGELOG apc_cache.c apc_cache.h apc_globals.h apc_main.c apc_sma.c php_apc.c Log: Remove expunge_cb stuff from the 3.0 branch. We can play with this in 3.1

http://cvs.php.net/viewvc.cgi/pecl/apc/CHANGELOG?r1=1.39.2.3&r2=1.39.2.4&diff_format=u Index: pecl/apc/CHANGELOG diff -u pecl/apc/CHANGELOG:1.39.2.3 pecl/apc/CHANGELOG:1.39.2.4 --- pecl/apc/CHANGELOG:1.39.2.3 Fri Mar 28 21:12:40 2008 +++ pecl/apc/CHANGELOG Sat Mar 29 06:38:40 2008 @@ -1,3 +1,6 @@ +3.0.19: 2008-03-29 +- Move expunge callback groundwork to 3.1 (Rasmus) + 3.0.18: 2008-03-28 - Revert memleak patch (Gopal) - Fix for bug #13504 (David Fraser) http://cvs.php.net/viewvc.cgi/pecl/apc/apc_cache.c?r1=3.145.2.2&r2=3.145.2.3&diff_format=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.145.2.2 pecl/apc/apc_cache.c:3.145.2.3 --- pecl/apc/apc_cache.c:3.145.2.2 Tue Mar 25 18:24:57 2008 +++ pecl/apc/apc_cache.c Sat Mar 29 06:38:40 2008 @@ -28,7 +28,7 @@ */ -/* $Id: apc_cache.c,v 3.145.2.2 2008/03/25 18:24:57 gopalv Exp $ */ +/* $Id: apc_cache.c,v 3.145.2.3 2008/03/29 06:38:40 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -54,8 +54,6 @@ #define key_equals(a, b) (a.inode==b.inode && a.device==b.device) /* }}} */ -static void apc_cache_expunge(apc_cache_t* cache, size_t size); - /* {{{ hash */ static unsigned int hash(apc_cache_key_t key) { @@ -265,7 +263,6 @@ for (i = 0; i < num_slots; i++) { cache->slots[i] = NULL; } - cache->expunge_cb = apc_cache_expunge; return cache; } @@ -307,21 +304,9 @@ /* }}} */ /* {{{ apc_cache_expunge */ -static void apc_cache_expunge(apc_cache_t* cache, size_t size) +void apc_cache_expunge(apc_cache_t* cache, time_t t) { int i; - time_t t; - TSRMLS_FETCH(); - -#if PHP_API_VERSION < 20041225 -#if HAVE_APACHE && defined(APC_PHP4_STAT) - t = ((request_rec *)SG(server_context))->request_time; -#else - t = time(0); -#endif -#else - t = sapi_get_request_time(TSRMLS_C); -#endif if(!cache) return; http://cvs.php.net/viewvc.cgi/pecl/apc/apc_cache.h?r1=3.46.2.2&r2=3.46.2.3&diff_format=u Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.46.2.2 pecl/apc/apc_cache.h:3.46.2.3 --- pecl/apc/apc_cache.h:3.46.2.2 Tue Mar 25 18:24:57 2008 +++ pecl/apc/apc_cache.h Sat Mar 29 06:38:40 2008 @@ -26,7 +26,7 @@ */ -/* $Id: apc_cache.h,v 3.46.2.2 2008/03/25 18:24:57 gopalv Exp $ */ +/* $Id: apc_cache.h,v 3.46.2.3 2008/03/29 06:38:40 rasmus Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -309,8 +309,6 @@ }; /* }}} */ -typedef void (*apc_expunge_cb_t)(T cache, size_t n); - /* {{{ struct definition: apc_cache_t */ struct apc_cache_t { void* shmaddr; /* process (local) address of shared cache */ @@ -319,12 +317,12 @@ int num_slots; /* number of slots in cache */ int gc_ttl; /* maximum time on GC list for a slot */ int ttl; /* if slot is needed and entry's access time is older than this ttl, remove it */ - apc_expunge_cb_t expunge_cb; /* cache specific expunge callback to free up sma memory */ }; /* }}} */ extern apc_cache_info_t* apc_cache_info(T cache, zend_bool limited); extern void apc_cache_free_info(apc_cache_info_t* info); +extern void apc_cache_expunge(apc_cache_t* cache, time_t t); extern void apc_cache_unlock(apc_cache_t* cache); extern zend_bool apc_cache_busy(apc_cache_t* cache); extern zend_bool apc_cache_write_lock(apc_cache_t* cache); http://cvs.php.net/viewvc.cgi/pecl/apc/apc_globals.h?r1=3.70.2.6&r2=3.70.2.7&diff_format=u Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.70.2.6 pecl/apc/apc_globals.h:3.70.2.7 --- pecl/apc/apc_globals.h:3.70.2.6 Fri Mar 28 22:09:34 2008 +++ pecl/apc/apc_globals.h Sat Mar 29 06:38:40 2008 @@ -29,7 +29,7 @@ */ -/* $Id: apc_globals.h,v 3.70.2.6 2008/03/28 22:09:34 rasmus Exp $ */ +/* $Id: apc_globals.h,v 3.70.2.7 2008/03/29 06:38:40 rasmus Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -88,7 +88,6 @@ zval *filehits; /* Files that came from the cache for this request */ #endif zend_bool coredump_unmap; /* Trap signals that coredump and unmap shared memory */ - apc_cache_t *current_cache; /* current cache being modified/read */ ZEND_END_MODULE_GLOBALS(apc) /* (the following declaration is defined in php_apc.c) */ http://cvs.php.net/viewvc.cgi/pecl/apc/apc_main.c?r1=3.103.2.2&r2=3.103.2.3&diff_format=u Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.103.2.2 pecl/apc/apc_main.c:3.103.2.3 --- pecl/apc/apc_main.c:3.103.2.2 Fri Mar 28 18:35:40 2008 +++ pecl/apc/apc_main.c Sat Mar 29 06:38:40 2008 @@ -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.3 2008/03/29 06:38:40 rasmus Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -430,10 +430,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); http://cvs.php.net/viewvc.cgi/pecl/apc/apc_sma.c?r1=1.69.2.2&r2=1.69.2.3&diff_format=u Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.69.2.2 pecl/apc/apc_sma.c:1.69.2.3 --- pecl/apc/apc_sma.c:1.69.2.2 Fri Mar 28 20:17:47 2008 +++ pecl/apc/apc_sma.c Sat Mar 29 06:38:40 2008 @@ -26,7 +26,7 @@ */ -/* $Id: apc_sma.c,v 1.69.2.2 2008/03/28 20:17:47 rasmus Exp $ */ +/* $Id: apc_sma.c,v 1.69.2.3 2008/03/29 06:38:40 rasmus Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -409,7 +409,6 @@ { size_t off; int i; - size_t *orig_mem_size_ptr; TSRMLS_FETCH(); assert(sma_initialized); http://cvs.php.net/viewvc.cgi/pecl/apc/php_apc.c?r1=3.154.2.2&r2=3.154.2.3&diff_format=u Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.154.2.2 pecl/apc/php_apc.c:3.154.2.3 --- pecl/apc/php_apc.c:3.154.2.2 Fri Mar 28 18:35:41 2008 +++ pecl/apc/php_apc.c Sat Mar 29 06:38:40 2008 @@ -26,7 +26,7 @@ */ -/* $Id: php_apc.c,v 3.154.2.2 2008/03/28 18:35:41 gopalv Exp $ */ +/* $Id: php_apc.c,v 3.154.2.3 2008/03/29 06:38:40 rasmus Exp $ */ #include "apc_zend.h" #include "apc_cache.h" @@ -226,7 +226,7 @@ #else php_info_print_table_row(2, "Locking type", "File Locks"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.154.2.2 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.154.2.3 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@ -559,18 +559,18 @@ HANDLE_BLOCK_INTERRUPTIONS(); APCG(mem_size_ptr) = &mem_size; - APCG(current_cache) = apc_user_cache; if (!(entry = apc_cache_make_user_entry(strkey, strkey_len + 1, val, ttl))) { APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; + apc_cache_expunge(apc_cache,t); + apc_cache_expunge(apc_user_cache,t); HANDLE_UNBLOCK_INTERRUPTIONS(); return 0; } if (!apc_cache_make_user_key(&key, strkey, strkey_len + 1, t)) { APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; apc_cache_free_entry(entry); + /* make_user_key doesn't allocate anything, so no expunge */ HANDLE_UNBLOCK_INTERRUPTIONS(); return 0; } @@ -578,13 +578,15 @@ if (!apc_cache_user_insert(apc_user_cache, key, entry, t, exclusive TSRMLS_CC)) { apc_cache_free_entry(entry); APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; + /* + No expunge here - user_insert can fail for non-memory related reasons + The alloc-based expunge hook in 3.1 will do a better job here + */ HANDLE_UNBLOCK_INTERRUPTIONS(); return 0; } APCG(mem_size_ptr) = NULL; - APCG(current_cache) = NULL; HANDLE_UNBLOCK_INTERRUPTIONS();
« previous php.pecl.cvs (#10104) next »