cvs: pecl /apc apc_cache.c apc_cache.h apc_main.c apc_sma.c

From: Date: Tue, 28 Feb 2006 01:45:55 +0000
Subject: cvs: pecl /apc apc_cache.c apc_cache.h apc_main.c apc_sma.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-5285@lists.php.net to get a copy of this message
rasmus Tue Feb 28 01:45:55 2006 UTC Modified files: /pecl/apc apc_cache.c apc_cache.h apc_main.c apc_sma.c Log: - Robustness fix to wraparound check. - Reset next fit search marker on a chunk delete - Add a busy flag to tell tell clients to not even try to use the cache during a clear/expunge http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_cache.c?r1=3.106&r2=3.107&diff_format=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.106 pecl/apc/apc_cache.c:3.107 --- pecl/apc/apc_cache.c:3.106 Mon Feb 27 16:29:43 2006 +++ pecl/apc/apc_cache.c Tue Feb 28 01:45:55 2006 @@ -28,7 +28,7 @@ */ -/* $Id: apc_cache.c,v 3.106 2006/02/27 16:29:43 rasmus Exp $ */ +/* $Id: apc_cache.c,v 3.107 2006/02/28 01:45:55 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -71,6 +71,7 @@ slot_t* deleted_list; /* linked list of to-be-deleted slots */ time_t start_time; /* time the above counters were reset */ int expunges; /* total number of expunges */ + zend_bool busy; /* Flag to tell clients when we are busy cleaning the cache */ }; /* }}} */ @@ -283,6 +284,7 @@ cache->header->deleted_list = NULL; cache->header->start_time = time(NULL); cache->header->expunges = 0; + cache->header->busy = 0; cache->slots = (slot_t**) (((char*) cache->shmaddr) + sizeof(header_t)); cache->num_slots = num_slots; @@ -314,7 +316,7 @@ if(!cache) return; LOCK(cache); - + cache->header->busy = 1; cache->header->num_hits = 0; cache->header->num_misses = 0; cache->header->start_time = time(NULL); @@ -328,6 +330,7 @@ cache->slots[i] = NULL; } + cache->header->busy = 0; UNLOCK(cache); } /* }}} */ @@ -345,6 +348,7 @@ * we run out of space. */ LOCK(cache); + cache->header->busy = 1; cache->header->expunges++; for (i = 0; i < cache->num_slots; i++) { slot_t* p = cache->slots[i]; @@ -353,6 +357,7 @@ } cache->slots[i] = NULL; } + cache->header->busy = 0; UNLOCK(cache); } else { slot_t **p; @@ -367,6 +372,7 @@ */ LOCK(cache); + cache->header->busy = 1; cache->header->expunges++; for (i = 0; i < cache->num_slots; i++) { p = &cache->slots[i]; @@ -394,6 +400,7 @@ p = &(*p)->next; } } + cache->header->busy = 0; UNLOCK(cache); } } @@ -958,6 +965,13 @@ } /* }}} */ +/* {{{ apc_cache_busy */ +zend_bool apc_cache_busy(apc_cache_t* cache) +{ + return cache->header->busy; +} +/* }}} */ + /* * Local variables: * tab-width: 4 http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_cache.h?r1=3.33&r2=3.34&diff_format=u Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.33 pecl/apc/apc_cache.h:3.34 --- pecl/apc/apc_cache.h:3.33 Sat Feb 25 19:50:33 2006 +++ pecl/apc/apc_cache.h Tue Feb 28 01:45:55 2006 @@ -26,7 +26,7 @@ */ -/* $Id: apc_cache.h,v 3.33 2006/02/25 19:50:33 rasmus Exp $ */ +/* $Id: apc_cache.h,v 3.34 2006/02/28 01:45:55 rasmus Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -270,6 +270,7 @@ 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); #undef T #endif http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_main.c?r1=3.68&r2=3.69&diff_format=u Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.68 pecl/apc/apc_main.c:3.69 --- pecl/apc/apc_main.c:3.68 Sat Feb 25 09:02:56 2006 +++ pecl/apc/apc_main.c Tue Feb 28 01:45:55 2006 @@ -28,7 +28,7 @@ */ -/* $Id: apc_main.c,v 3.68 2006/02/25 09:02:56 rasmus Exp $ */ +/* $Id: apc_main.c,v 3.69 2006/02/28 01:45:55 rasmus Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -211,7 +211,7 @@ char *path; size_t mem_size; - if (!APCG(enabled)) { + if (!APCG(enabled) || apc_cache_busy(apc_cache)) { return old_compile_file(h, type TSRMLS_CC); } http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_sma.c?r1=1.41&r2=1.42&diff_format=u Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.41 pecl/apc/apc_sma.c:1.42 --- pecl/apc/apc_sma.c:1.41 Sun Feb 26 23:30:48 2006 +++ pecl/apc/apc_sma.c Tue Feb 28 01:45:55 2006 @@ -26,7 +26,7 @@ */ -/* $Id: apc_sma.c,v 1.41 2006/02/26 23:30:48 rasmus Exp $ */ +/* $Id: apc_sma.c,v 1.42 2006/02/28 01:45:55 rasmus Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -100,6 +100,7 @@ block_t* prvnextfit; /* block before next fit */ size_t realsize; /* actual size of block needed, including header */ size_t last_offset; /* save the last search offset */ + int wrapped=0; realsize = alignword(max(size + alignword(sizeof(int)), sizeof(block_t))); @@ -126,24 +127,30 @@ /* If it fits perfectly or it fits after a split, stop searching */ if (cur->size == realsize || (cur->size > (sizeof(block_t) + realsize))) { prvnextfit = prv; + header->nfoffset = last_offset; /* Next time we search, start at this offset */ break; } - last_offset = prv->next; prv = cur; + if(wrapped && (prv->next >= header->nfoffset)) break; + last_offset = prv->next; + /* Check to see if we need to wrap around and search from the top */ if(header->nfoffset && prv->next == 0) { prv = BLOCKAT(sizeof(header_t)); + wrapped = 1; } } if (prvnextfit == 0) { + header->nfoffset = 0; return -1; } - header->nfoffset = last_offset; /* Next time we search, start at this offset */ prv = prvnextfit; cur = BLOCKAT(prv->next); + header->nfoffset = last_offset; /* Next time we search, start at this offset */ + /* update the block header */ header->avail -= realsize; #if ALLOC_DISTRIBUTION @@ -214,6 +221,7 @@ cur->size += nxt->size; cur->next = nxt->next; } + header->nfoffset = 0; /* Reset the next fit search marker */ return size; }

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