cvs: pecl /apc apc_main.c apc_sma.c

From: Date: Tue, 07 Sep 2004 20:24:34 +0000
Subject: cvs: pecl /apc apc_main.c apc_sma.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-1802@lists.php.net to get a copy of this message
rasmus Tue Sep 7 16:24:34 2004 EDT Modified files: /pecl/apc apc_main.c apc_sma.c Log: Turn locking functions in apc_sma.c into a set of locking macros to make it easier to replace the locking mechanism for people who need that. Benchmarked blocking interruptions in the sma locking macros, but the performance hit was too big, so blocked at a higher level in apc_main.c instead around the major shared memory copy functions. Finally, support the case where the we don't get a filepath passed in via the zend_file_handle. In this case pick the filepath out of the cache entry. http://cvs.php.net/diff.php/pecl/apc/apc_main.c?r1=3.17&r2=3.18&ty=u Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.17 pecl/apc/apc_main.c:3.18 --- pecl/apc/apc_main.c:3.17 Thu Sep 2 19:08:31 2004 +++ pecl/apc/apc_main.c Tue Sep 7 16:24:29 2004 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_main.c,v 3.17 2004/09/02 23:08:31 rasmus Exp $ */ +/* $Id: apc_main.c,v 3.18 2004/09/07 20:24:29 rasmus Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -148,6 +148,9 @@ /* search for the file in the cache */ cache_entry = apc_cache_find(APCG(cache), key); if (cache_entry != NULL) { + if (h->opened_path == NULL) { + h->opened_path = estrdup(cache_entry->filename); + } zend_llist_add_element(&CG(open_files), h); /* XXX kludge */ apc_stack_push(APCG(cache_stack), cache_entry); return cached_compile(TSRMLS_C); @@ -163,22 +166,27 @@ return NULL; } + HANDLE_BLOCK_INTERRUPTIONS(); if(!(alloc_op_array = apc_copy_op_array(NULL, op_array, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_log(APC_WARNING, "(apc_copy_op_array) unable to cache '%s': insufficient " "shared memory available", h->opened_path); + HANDLE_UNBLOCK_INTERRUPTIONS(); return op_array; } if(!(alloc_functions = apc_copy_new_functions(num_functions, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_log(APC_WARNING, "(apc_copy_new_functions) unable to cache '%s': insufficient " "shared memory available", h->opened_path); apc_free_op_array(alloc_op_array, apc_sma_free); + HANDLE_UNBLOCK_INTERRUPTIONS(); return op_array; } if(!(alloc_classes = apc_copy_new_classes(op_array, num_classes, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_log(APC_WARNING, "(apc_copy_new_classes) unable to cache '%s': insufficient " "shared memory available", h->opened_path); apc_free_op_array(alloc_op_array, apc_sma_free); apc_free_functions(alloc_functions, apc_sma_free); + HANDLE_UNBLOCK_INTERRUPTIONS(); return op_array; } + HANDLE_UNBLOCK_INTERRUPTIONS(); /* cache the compiler results */ cache_entry = apc_cache_make_entry(h->opened_path, alloc_op_array, alloc_functions, alloc_classes); @@ -336,7 +344,7 @@ /* {{{ apc_version */ const char* apc_version() { - return "2.0.4"; + return "2.0.5"; } /* }}} */ http://cvs.php.net/diff.php/pecl/apc/apc_sma.c?r1=1.18&r2=1.19&ty=u Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.18 pecl/apc/apc_sma.c:1.19 --- pecl/apc/apc_sma.c:1.18 Sat Sep 4 10:33:13 2004 +++ pecl/apc/apc_sma.c Tue Sep 7 16:24:30 2004 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_sma.c,v 1.18 2004/09/04 14:33:13 rasmus Exp $ */ +/* $Id: apc_sma.c,v 1.19 2004/09/07 20:24:30 rasmus Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -26,6 +26,11 @@ void apc_unmap(void* shmaddr, int size); #endif +/* {{{ locking macros */ +#define LOCK(c) apc_lck_lock(c) +#define UNLOCK(c) apc_lck_unlock(c) +/* }}} */ + enum { POWER_OF_TWO_BLOCKSIZE=0 }; /* force allocated blocks to 2^n? */ enum { DEFAULT_NUMSEG=1, DEFAULT_SEGSIZE=30*1024*1024 }; @@ -291,12 +296,12 @@ int i; assert(sma_initialized); - apc_lck_lock(sma_lock); + LOCK(sma_lock); off = sma_allocate(sma_shmaddrs[sma_lastseg], n); if (off != -1) { void* p = (void *)(((char *)(sma_shmaddrs[sma_lastseg])) + off); - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); return p; } @@ -307,13 +312,13 @@ off = sma_allocate(sma_shmaddrs[i], n); if (off != -1) { void* p = (void *)(((char *)(sma_shmaddrs[i])) + off); - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); sma_lastseg = i; return p; } } - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); return NULL; } /* }}} */ @@ -327,20 +332,20 @@ return; } - apc_lck_lock(sma_lock); + LOCK(sma_lock); assert(sma_initialized); for (i = 0; i < sma_numseg; i++) { - unsigned int d_size = (unsigned int)((char *)p - (char *)(sma_shmaddrs[i])); + unsigned int d_size = (unsigned int)((char *)p - (char *)(sma_shmaddrs[i])); if (p >= sma_shmaddrs[i] && d_size < sma_segsize) { sma_deallocate(sma_shmaddrs[i], d_size); - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); return; } } apc_eprint("apc_sma_free: could not locate address %p", p); - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); } /* }}} */ @@ -364,7 +369,7 @@ info->list[i] = NULL; } - apc_lck_lock(sma_lock); + LOCK(sma_lock); /* For each segment */ for (i = 0; i < sma_numseg; i++) { @@ -387,7 +392,7 @@ } } - apc_lck_unlock(sma_lock); + UNLOCK(sma_lock); return info; } /* }}} */

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