cvs: pecl /apc .cvsignore apc.c apc.h apc.php apc_cache.c apc_cache.h apc_compile.c apc_compile.h apc_main.c apc_sma.c php_apc.c

From: Date: Thu, 07 Apr 2005 23:22:09 +0000
Subject: cvs: pecl /apc .cvsignore apc.c apc.h apc.php apc_cache.c apc_cache.h apc_compile.c apc_compile.h apc_main.c apc_sma.c php_apc.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-2950@lists.php.net to get a copy of this message
rasmus Thu Apr 7 19:22:09 2005 EDT Modified files: /pecl/apc .cvsignore apc.c apc.h apc.php apc_cache.c apc_cache.h apc_compile.c apc_compile.h apc_main.c apc_sma.c php_apc.c Log: Fix cache expunge problems.

http://cvs.php.net/diff.php/pecl/apc/.cvsignore?r1=1.1&r2=1.2&ty=u Index: pecl/apc/.cvsignore diff -u pecl/apc/.cvsignore:1.1 pecl/apc/.cvsignore:1.2 --- pecl/apc/.cvsignore:1.1 Mon Sep 27 03:39:37 2004 +++ pecl/apc/.cvsignore Thu Apr 7 19:22:06 2005 @@ -1,5 +1,48 @@ -*.plg -*.opt -*.ncb -Release_TS -Debug_TS +.cvsignore +.deps +.libs +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +acinclude.m4 +aclocal.m4 +apc.la +apc.lo +apc_cache.lo +apc_compile.lo +apc_sem.lo +apc_shm.lo +apc_sma.lo +apc_stack.lo +apc_zend.lo +apc_main.lo +apc_mmap.lo +autom4te.cache +build +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.in +include +install-sh +libtool +ltmain.sh +missing +mkinstalldirs +modules +o +php_apc.lo +scan_makefile_in.awk +conftest.c +apc_debug.lo +apc_fcntl.lo +apc_optimizer.lo +apc_pair.lo +config.cache +conftest http://cvs.php.net/diff.php/pecl/apc/apc.c?r1=3.3&r2=3.4&ty=u Index: pecl/apc/apc.c diff -u pecl/apc/apc.c:3.3 pecl/apc/apc.c:3.4 --- pecl/apc/apc.c:3.3 Mon Jun 28 04:54:15 2004 +++ pecl/apc/apc.c Thu Apr 7 19:22:06 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc.c,v 3.3 2004/06/28 08:54:15 rasmus Exp $ */ +/* $Id: apc.c,v 3.4 2005/04/07 23:22:06 rasmus Exp $ */ #include "apc.h" #include <regex.h> /* for POSIX regular expressions */ @@ -150,10 +150,10 @@ void apc_dprint(const char* fmt, ...) { -#ifdef APC_DEBUG +#ifdef APC_DBG va_list args; va_start(args, fmt); - my_log(APC_DEBUG, fmt, args); + my_log(APC_DBG, fmt, args); va_end(args); #endif } http://cvs.php.net/diff.php/pecl/apc/apc.h?r1=3.6&r2=3.7&ty=u Index: pecl/apc/apc.h diff -u pecl/apc/apc.h:3.6 pecl/apc/apc.h:3.7 --- pecl/apc/apc.h:3.6 Sun Sep 26 11:13:25 2004 +++ pecl/apc/apc.h Thu Apr 7 19:22:06 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc.h,v 3.6 2004/09/26 15:13:25 rasmus Exp $ */ +/* $Id: apc.h,v 3.7 2005/04/07 23:22:06 rasmus Exp $ */ #ifndef APC_H #define APC_H @@ -37,14 +37,12 @@ #include <sys/stat.h> #include <unistd.h> -#ifdef HAVE_CONFIG_H +#ifndef PHP_WIN32 #include "config.h" #endif -#include "php.h" - /* log levels constants (see apc_log) */ -enum { APC_DEBUG, APC_NOTICE, APC_WARNING, APC_ERROR }; +enum { APC_DBG, APC_NOTICE, APC_WARNING, APC_ERROR }; /* typedefs for extensible memory allocators */ typedef void* (*apc_malloc_t)(size_t); http://cvs.php.net/diff.php/pecl/apc/apc.php?r1=3.2&r2=3.3&ty=u Index: pecl/apc/apc.php diff -u pecl/apc/apc.php:3.2 pecl/apc/apc.php:3.3 --- pecl/apc/apc.php:3.2 Sun Sep 12 03:11:22 2004 +++ pecl/apc/apc.php Thu Apr 7 19:22:06 2005 @@ -2,7 +2,7 @@ function redir($arg="") { $port = getenv('SERVER_PORT'); $host = getenv('HTTP_HOST'); - $self = $_SERVER['PHP_SELF']; + $self = getenv('PHP_SELF'); if($port==443) $url = "https://"; else $url = "http://"; $url .= $host; http://cvs.php.net/diff.php/pecl/apc/apc_cache.c?r1=3.76&r2=3.77&ty=u Index: pecl/apc/apc_cache.c diff -u pecl/apc/apc_cache.c:3.76 pecl/apc/apc_cache.c:3.77 --- pecl/apc/apc_cache.c:3.76 Wed Nov 24 09:27:30 2004 +++ pecl/apc/apc_cache.c Thu Apr 7 19:22:06 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.c,v 3.76 2004/11/24 14:27:30 rasmus Exp $ */ +/* $Id: apc_cache.c,v 3.77 2005/04/07 23:22:06 rasmus Exp $ */ #include "apc_cache.h" #include "apc_lock.h" @@ -136,8 +136,9 @@ /* {{{ free_slot */ static void free_slot(slot_t* slot) { - if(slot->value->type == APC_CACHE_ENTRY_USER) + if(slot->value->type == APC_CACHE_ENTRY_USER) { apc_sma_free(slot->key.data.user.identifier); + } apc_cache_free_entry(slot->value); apc_sma_free(slot); } @@ -304,19 +305,44 @@ void apc_cache_expunge(apc_cache_t* cache, time_t t) { int i; - slot_t *p; + slot_t **p; + /* + * We don't do any cache cleanup here unless the ttl for the cache + * has been set. For the user cache that is slightly confusing since + * we have the individual entry ttl's we can look at, but that would be + * too much work. So if you want the user cache expunged, set a high + * default apc.user_ttl and still provide a specific ttl for each entry + * on insert + */ if(!cache || (cache && !cache->ttl)) return; + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expunge called"); LOCK(cache); for (i = 0; i < cache->num_slots; i++) { - p = cache->slots[i]; - while(p) { - if(p->access_time < (t - cache->ttl)) { - remove_slot(cache, &p); + p = &cache->slots[i]; + while(*p) { + /* + * For the user cache we look at the individual entry ttl values + * and if not set fall back to the default ttl for the user cache + */ + if((*p)->value->type == APC_CACHE_ENTRY_USER) { + if((*p)->value->data.user.ttl) { + if((*p)->creation_time + (*p)->value->data.user.ttl < t) { + remove_slot(cache, p); + continue; + } + } else if(cache->ttl) { + if((*p)->creation_time + cache->ttl < t) { + remove_slot(cache, p); + continue; + } + } + } else if((*p)->access_time < (t - cache->ttl)) { + remove_slot(cache, p); continue; } - p = p->next; + p = &(*p)->next; } } UNLOCK(cache); @@ -342,8 +368,7 @@ while (*slot) { if (key_equals((*slot)->key.data.file, key.data.file)) { - /* If existing slot for the same device+inode has a different - mtime, remove it and insert the new version */ + /* If existing slot for the same device+inode is different, remove it and insert the new version */ if ((*slot)->key.mtime != key.mtime) { remove_slot(cache, slot); break; http://cvs.php.net/diff.php/pecl/apc/apc_cache.h?r1=3.23&r2=3.24&ty=u Index: pecl/apc/apc_cache.h diff -u pecl/apc/apc_cache.h:3.23 pecl/apc/apc_cache.h:3.24 --- pecl/apc/apc_cache.h:3.23 Sun Nov 14 13:07:25 2004 +++ pecl/apc/apc_cache.h Thu Apr 7 19:22:07 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_cache.h,v 3.23 2004/11/14 18:07:25 rasmus Exp $ */ +/* $Id: apc_cache.h,v 3.24 2005/04/07 23:22:07 rasmus Exp $ */ #ifndef APC_CACHE_H #define APC_CACHE_H @@ -193,6 +193,7 @@ extern apc_cache_entry_t* apc_cache_make_user_entry(const char* info, const zval *val, const unsigned int ttl); extern int apc_cache_make_user_key(apc_cache_key_t* key, char* identifier, const time_t t); +extern int apc_cache_free_user_key(apc_cache_key_t* key); /* * Frees all memory associated with an object returned by apc_cache_make_entry @@ -243,6 +244,7 @@ extern apc_cache_info_t* apc_cache_info(T cache); extern void apc_cache_free_info(apc_cache_info_t* info); +extern void apc_cache_expunge(apc_cache_t* cache, time_t t); #undef T #endif http://cvs.php.net/diff.php/pecl/apc/apc_compile.c?r1=3.14&r2=3.15&ty=u Index: pecl/apc/apc_compile.c diff -u pecl/apc/apc_compile.c:3.14 pecl/apc/apc_compile.c:3.15 --- pecl/apc/apc_compile.c:3.14 Sat Nov 6 13:12:10 2004 +++ pecl/apc/apc_compile.c Thu Apr 7 19:22:07 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.c,v 3.14 2004/11/06 18:12:10 rasmus Exp $ */ +/* $Id: apc_compile.c,v 3.15 2005/04/07 23:22:07 rasmus Exp $ */ #include "apc_compile.h" #include "apc_globals.h" @@ -208,10 +208,11 @@ case IS_CONSTANT: case IS_STRING: case FLAG_IS_BC: - if (src->value.str.val) + if (src->value.str.val) { CHECK(dst->value.str.val = apc_xmemcpy(src->value.str.val, src->value.str.len+1, allocate)); + } break; case IS_ARRAY: @@ -444,7 +445,6 @@ return NULL; } } - dst->builtin_functions[n].fname = NULL; } @@ -577,7 +577,7 @@ /* }}} */ /* {{{ apc_copy_zval */ -zval* apc_copy_zval(zval* dst, const zval* src, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC) +zval* apc_copy_zval(zval* dst, const zval* src, apc_malloc_t allocate, apc_free_t deallocate) { int local_dst_alloc = 0; assert(src != NULL); @@ -1159,7 +1159,7 @@ /* {{{ apc_copy_function_for_execution_ex */ zend_function* apc_copy_function_for_execution_ex(void *dummy, zend_function* src) { - if(src->type==ZEND_INTERNAL_FUNCTION || src->type==ZEND_OVERLOADED_FUNCTION) return src; + if(src->type==ZEND_INTERNAL_FUNCTION || src->type==ZEND_OVERLOADED_FUNCTION) return src; return apc_copy_function_for_execution(src); } /* }}} */ http://cvs.php.net/diff.php/pecl/apc/apc_compile.h?r1=3.6&r2=3.7&ty=u Index: pecl/apc/apc_compile.h diff -u pecl/apc/apc_compile.h:3.6 pecl/apc/apc_compile.h:3.7 --- pecl/apc/apc_compile.h:3.6 Sun Sep 12 10:31:44 2004 +++ pecl/apc/apc_compile.h Thu Apr 7 19:22:07 2005 @@ -2,10 +2,10 @@ +----------------------------------------------------------------------+ | Copyright (c) 2002 by Community Connect Inc. All rights reserved. | +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, | + | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | - | http://www.php.net/license/3_0.txt. | + | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_compile.h,v 3.6 2004/09/12 14:31:44 rasmus Exp $ */ +/* $Id: apc_compile.h,v 3.7 2005/04/07 23:22:07 rasmus Exp $ */ #ifndef APC_COMPILE_H #define APC_COMPILE_H @@ -56,7 +56,7 @@ extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_malloc_t allocate, apc_free_t deallocate); extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC); extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC); -extern zval* apc_copy_zval(zval* dst, const zval* src, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC); +extern zval* apc_copy_zval(zval* dst, const zval* src, apc_malloc_t allocate, apc_free_t deallocate); /* * Deallocation functions corresponding to the copy functions above. http://cvs.php.net/diff.php/pecl/apc/apc_main.c?r1=3.27&r2=3.28&ty=u Index: pecl/apc/apc_main.c diff -u pecl/apc/apc_main.c:3.27 pecl/apc/apc_main.c:3.28 --- pecl/apc/apc_main.c:3.27 Thu Feb 3 10:33:12 2005 +++ pecl/apc/apc_main.c Thu Apr 7 19:22:07 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_main.c,v 3.27 2005/02/03 15:33:12 rasmus Exp $ */ +/* $Id: apc_main.c,v 3.28 2005/04/07 23:22:07 rasmus Exp $ */ #include "apc_php.h" #include "apc_main.h" @@ -182,24 +182,24 @@ HANDLE_BLOCK_INTERRUPTIONS(); if(!(alloc_op_array = apc_copy_op_array(NULL, op_array, apc_sma_malloc, apc_sma_free TSRMLS_CC))) { apc_cache_expunge(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); HANDLE_UNBLOCK_INTERRUPTIONS(); - apc_log(APC_WARNING, "(apc_copy_op_array) unable to cache '%s': insufficient " "shared memory available", h->opened_path?h->opened_path:""); return op_array; } 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(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); HANDLE_UNBLOCK_INTERRUPTIONS(); - apc_log(APC_WARNING, "(apc_copy_new_functions) unable to cache '%s': insufficient " "shared memory available", h->opened_path?h->opened_path:""); return op_array; } 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(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); HANDLE_UNBLOCK_INTERRUPTIONS(); - apc_log(APC_WARNING, "(apc_copy_new_classes) unable to cache '%s': insufficient " "shared memory available", h->opened_path?h->opened_path:""); return op_array; } @@ -208,8 +208,8 @@ apc_free_functions(alloc_functions, apc_sma_free); apc_free_classes(alloc_classes, apc_sma_free); apc_cache_expunge(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); HANDLE_UNBLOCK_INTERRUPTIONS(); - apc_log(APC_WARNING, "(apc_cache_make_file_entry) unable to cache '%s': insufficient " "shared memory available", h->opened_path?h->opened_path:""); return op_array; } HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -218,7 +218,7 @@ apc_cache_free_entry(cache_entry); if(ret==-1) { apc_cache_expunge(APCG(cache),t); - apc_log(APC_WARNING, "(apc_cache_insert) unable to cache '%s': insufficient " "shared memory available", h->opened_path?h->opened_path:""); + apc_cache_expunge(APCG(user_cache),t); } } http://cvs.php.net/diff.php/pecl/apc/apc_sma.c?r1=1.23&r2=1.24&ty=u Index: pecl/apc/apc_sma.c diff -u pecl/apc/apc_sma.c:1.23 pecl/apc/apc_sma.c:1.24 --- pecl/apc/apc_sma.c:1.23 Fri Sep 24 00:08:18 2004 +++ pecl/apc/apc_sma.c Thu Apr 7 19:22:07 2005 @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apc_sma.c,v 1.23 2004/09/24 04:08:18 rasmus Exp $ */ +/* $Id: apc_sma.c,v 1.24 2005/04/07 23:22:07 rasmus Exp $ */ #include "apc_sma.h" #include "apc.h" @@ -87,7 +87,7 @@ /* Realsize must be aligned to a word boundary on some architectures. */ realsize = alignword(max(size + alignword(sizeof(int)), sizeof(block_t))); - + /* * Set realsize to the smallest power of 2 greater than or equal to * realsize. This increases the likelihood that neighboring blocks can be @@ -317,8 +317,8 @@ off = sma_allocate(sma_shmaddrs[i], n); if (off != -1) { void* p = (void *)(((char *)(sma_shmaddrs[i])) + off); - sma_lastseg = i; UNLOCK(sma_lock); + sma_lastseg = i; return p; } } @@ -458,6 +458,7 @@ } /* }}} */ +#if 0 /* {{{ apc_sma_check_integrity */ void apc_sma_check_integrity() { @@ -481,6 +482,7 @@ } } /* }}} */ +#endif /* * Local variables: http://cvs.php.net/diff.php/pecl/apc/php_apc.c?r1=3.41&r2=3.42&ty=u Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.41 pecl/apc/php_apc.c:3.42 --- pecl/apc/php_apc.c:3.41 Sun Nov 14 13:07:25 2004 +++ pecl/apc/php_apc.c Thu Apr 7 19:22:07 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apc.c,v 3.41 2004/11/14 18:07:25 rasmus Exp $ */ +/* $Id: php_apc.c,v 3.42 2005/04/07 23:22:07 rasmus Exp $ */ #ifdef PHP_WIN32 /* XXX lame hack, for some reason, the ini entries are all messed @@ -127,7 +127,7 @@ #else php_info_print_table_row(2, "MMAP Support", "Disabled"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.41 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.42 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@ -142,6 +142,10 @@ REGISTER_INI_ENTRIES(); + /* Disable APC in cli mode */ + if(!strcmp(sapi_module.name, "cli")) + APCG(enabled) = 0; + if (APCG(enabled)) apc_module_init(); @@ -346,6 +350,8 @@ time_t t; if (!(entry = apc_cache_make_user_entry(strkey, val, ttl))) { + apc_cache_expunge(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); return 0; } @@ -359,12 +365,16 @@ if (!apc_cache_make_user_key(&key, strkey, t)) { apc_cache_free_entry(entry); + apc_cache_expunge(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); return 1; } if (!apc_cache_user_insert(APCG(user_cache), key, entry, t)) { apc_cache_free_user_key(&key); apc_cache_free_entry(entry); + apc_cache_expunge(APCG(cache),t); + apc_cache_expunge(APCG(user_cache),t); return 0; } @@ -390,6 +400,10 @@ } /* }}} */ +void *apc_erealloc_wrapper(void *ptr, size_t size) { + return _erealloc(ptr, size, 0); +} + /* {{{ proto mixed apc_fetch(string key) */ PHP_FUNCTION(apc_fetch) { @@ -447,7 +461,7 @@ } /* }}} */ -static void _apc_define_constants(zval *constants, zend_bool case_sensitive) { +static void _apc_define_constants(zval *constants, zend_bool case_sensitive TSRMLS_DC) { char *const_key; int const_key_len; zval **entry; @@ -490,7 +504,6 @@ PHP_FUNCTION(apc_define_constants) { char *strkey; int strkey_len; - ulong num_key; zval *constants = NULL; zend_bool case_sensitive = 1; int argc = ZEND_NUM_ARGS();
« previous php.pecl.cvs (#2950) next »