cvs: pecl /apc apc_cache.c

From: Date: Thu, 26 Jun 2003 08:03:06 +0000
Subject: cvs: pecl /apc apc_cache.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-312@lists.php.net to get a copy of this message
gschlossnagle Thu Jun 26 04:03:06 2003 EDT Modified files: /pecl/apc apc_cache.c Log: This doesnt' work at all here VS: ---------------------------------------------------------------------- Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.44 pecl/apc/apc_cache.c:3.45 --- pecl/apc/apc_cache.c:3.44 Thu Jun 26 03:57:56 2003 +++ pecl/apc/apc_cache.c Thu Jun 26 04:03:06 2003 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.c,v 3.44 2003/06/26 07:57:56 sterling Exp $ */ +/* $Id: apc_cache.c,v 3.45 2003/06/26 08:03:06 gschlossnagle Exp $ */ #include "apc_cache.h" #include "apc_sem.h" @@ -57,7 +57,6 @@ header_t* header; /* cache header (stored in SHM) */ slot_t** slots; /* array of cache slots (stored in SHM) */ int num_slots; /* number of slots in cache */ - int mask; /* mask to find the current slot */ int gc_ttl; /* maximum time on GC list for a slot */ int lock; /* global semaphore lock */ }; @@ -202,7 +201,6 @@ cache->slots = (slot_t**) (((char*) cache->shmaddr) + sizeof(header_t)); cache->num_slots = num_slots; - cache->mask = 1 << num_slots; cache->gc_ttl = gc_ttl; cache->lock = CREATE_LOCK; @@ -258,7 +256,7 @@ LOCK(cache); process_pending_removals(cache); - slot = &cache->slots[hash(key) & cache->mask]; + slot = &cache->slots[hash(key) % cache->num_slots]; while (*slot) { if (key_equals((*slot)->key, key)) { if ((*slot)->key.mtime < key.mtime) { @@ -284,27 +282,27 @@ /* {{{ apc_cache_find */ apc_cache_entry_t* apc_cache_find(apc_cache_t* cache, apc_cache_key_t key) { - slot_t* slot; - - LOCK(cache); - - slot = cache->slots[hash(key) & cache->mask]; - while (slot) { - if (key_equals(slot->key, key)) { - if (slot->key.mtime != key.mtime) { - remove_slot(cache, &cache->slots[hash(key) & cache->mask]); + slot_t** slot; + + LOCK(cache); + + slot = &cache->slots[hash(key) % cache->num_slots]; + while (*slot) { + if (key_equals((*slot)->key, key)) { + if ((*slot)->key.mtime < key.mtime) { + remove_slot(cache, slot); break; } - slot->num_hits++; - slot->value->ref_count++; - prevent_garbage_collection(slot->value); + (*slot)->num_hits++; + (*slot)->value->ref_count++; + prevent_garbage_collection((*slot)->value); cache->header->num_hits++; UNLOCK(cache); - return slot->value; + return (*slot)->value; } - slot = slot->next; + slot = &(*slot)->next; } cache->header->num_misses++;

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