diff --git a/lang/php5/patches/005-APC.patch b/lang/php5/patches/005-APC.patch index a52977477..b6c5e3b81 100644 --- a/lang/php5/patches/005-APC.patch +++ b/lang/php5/patches/005-APC.patch @@ -1,11 +1,12 @@ ---- /dev/null -+++ b/ext/apc/apc_bin.c +diff -Naur a/ext/apc/apc_bin.c b/ext/apc/apc_bin.c +--- a/ext/apc/apc_bin.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_bin.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,987 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -20,7 +21,7 @@ + + */ + -+/* $Id: apc_bin.c 303383 2010-09-15 08:15:58Z dmitry $ */ ++/* $Id: apc_bin.c 324017 2012-03-08 09:46:22Z pajoye $ */ + +/* Creates a binary architecture specific output to a string or file containing + * the current cache contents for both fies and user variables. This is accomplished @@ -31,6 +32,7 @@ +#include "apc_globals.h" +#include "apc_bin.h" +#include "apc_zend.h" ++#include "apc_php.h" +#include "apc_sma.h" +#include "apc_pool.h" +#include "ext/standard/md5.h" @@ -54,6 +56,7 @@ + printf("%x in %s on line %d", ptr, __FILE__, __LINE__); \ + } else if((long)ptr > bd->size) { /* not swizzled */ \ + apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ ++ return; \ + } \ + printf("\n"); \ + } while(0); @@ -73,6 +76,7 @@ + ptr = (void*)((long)(ptr) - (long)(bd)); \ + } else if((ulong)ptr > bd->size) { /* not swizzled */ \ + apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ ++ return NULL; \ + } \ + } while(0); + @@ -123,6 +127,7 @@ + size_t *size; + if(zend_hash_index_find(&APCG(apc_bd_alloc_list), (ulong)ptr, (void**)&size) == FAILURE) { + apc_error("apc_bd_free could not free pointer (not found in list: %x)" TSRMLS_CC, ptr); ++ return; + } + APCG(apc_bd_alloc_ptr) = (void*)((size_t)APCG(apc_bd_alloc_ptr) - *size); + zend_hash_index_del(&APCG(apc_bd_alloc_list), (ulong)ptr); @@ -149,6 +154,7 @@ +#endif + if(APCG(apc_bd_alloc_ptr) > APCG(apc_bd_alloc_ubptr)) { + apc_error("Exceeded bounds check in apc_bd_alloc_ex by %d bytes." TSRMLS_CC, (unsigned char *) APCG(apc_bd_alloc_ptr) - (unsigned char *) APCG(apc_bd_alloc_ubptr)); ++ return NULL; + } + zend_hash_index_update(&APCG(apc_bd_alloc_list), (ulong)rval, &size, sizeof(size_t), NULL); + } @@ -168,6 +174,7 @@ +#endif + } else if((ulong)ptr > bd->size) { + apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, *ptr, ((long)bd + bd->size), file, line); \ ++ return; + } + } +} /* }}} */ @@ -292,8 +299,6 @@ + apc_swizzle_hashtable(bd, ll, &ce->function_table, (apc_swizzle_cb_t)apc_swizzle_function, 0 TSRMLS_CC); +#ifdef ZEND_ENGINE_2_4 + if (ce->default_properties_table) { -+ int i; -+ + for (i = 0; i < ce->default_properties_count; i++) { + if (ce->default_properties_table[i]) { + apc_swizzle_ptr(bd, ll, &ce->default_properties_table[i]); @@ -311,8 +316,6 @@ + +#ifdef ZEND_ENGINE_2_4 + if (ce->default_static_members_table) { -+ int i; -+ + for (i = 0; i < ce->default_static_members_count; i++) { + if (ce->default_static_members_table[i]) { + apc_swizzle_ptr(bd, ll, &ce->default_static_members_table[i]); @@ -444,7 +447,7 @@ + zend_hash_index_update(&APCG(copied_zvals), (ulong)zv, (void**)&zv, sizeof(zval*), NULL); + } + -+ switch(zv->type & ~IS_CONSTANT_INDEX) { ++ switch(zv->type & IS_CONSTANT_TYPE_MASK) { + case IS_NULL: + case IS_LONG: + case IS_DOUBLE: @@ -554,7 +557,6 @@ + PHP_MD5Final(digest, &context); + if(memcmp(md5_orig, digest, 16)) { + apc_error("MD5 checksum of binary dump failed." TSRMLS_CC); -+ memcpy(bd->md5, md5_orig, 16); /* add back md5 checksum */ + return -1; + } + } @@ -566,7 +568,6 @@ + } + if(crc_orig != crc) { + apc_error("CRC32 checksum of binary dump failed." TSRMLS_CC); -+ bd->crc = crc_orig; + return -1; + } + } @@ -988,14 +989,15 @@ + * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_bin.h +diff -Naur a/ext/apc/apc_bin.h b/ext/apc/apc_bin.h +--- a/ext/apc/apc_bin.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_bin.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,63 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -1010,7 +1012,7 @@ + + */ + -+/* $Id: apc_bin.h 300979 2010-07-04 10:15:05Z kalle $ */ ++/* $Id: apc_bin.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_BINDUMP_H +#define APC_BINDUMP_H @@ -1054,14 +1056,15 @@ + * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc.c -@@ -0,0 +1,636 @@ +diff -Naur a/ext/apc/apc.c b/ext/apc/apc.c +--- a/ext/apc/apc.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,670 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -1088,11 +1091,12 @@ + + */ + -+/* $Id: apc.c 305003 2010-10-31 19:45:10Z gopalv $ */ ++/* $Id: apc.c 326710 2012-07-19 20:51:04Z rasmus $ */ + +#include "apc.h" +#include "apc_zend.h" +#include "apc_cache.h" ++#include "apc_globals.h" +#include "php.h" + +#if HAVE_PCRE || HAVE_BUNDLED_PCRE @@ -1114,28 +1118,32 @@ + void* p = malloc(n); + if (p == NULL) { + apc_error("apc_emalloc: malloc failed to allocate %u bytes:" TSRMLS_CC, n); ++ return NULL; + } + return p; +} + +void* apc_erealloc(void* p, size_t n TSRMLS_DC) +{ -+ p = realloc(p, n); -+ if (p == NULL) { ++ void *new; ++ new = realloc(p, n); ++ if (new == NULL) { + apc_error("apc_erealloc: realloc failed to allocate %u bytes:" TSRMLS_CC, n); ++ return NULL; + } -+ return p; ++ return new; +} + +void apc_efree(void* p TSRMLS_DC) +{ + if (p == NULL) { + apc_error("apc_efree: attempt to free null pointer" TSRMLS_CC); ++ return; + } + free(p); +} + -+char* apc_estrdup(const char* s TSRMLS_DC) ++char* APC_ALLOC apc_estrdup(const char* s TSRMLS_DC) +{ + int len; + char* dup; @@ -1147,18 +1155,19 @@ + dup = (char*) malloc(len+1); + if (dup == NULL) { + apc_error("apc_estrdup: malloc failed to allocate %u bytes:" TSRMLS_CC, len+1); ++ return NULL; + } + memcpy(dup, s, len); + dup[len] = '\0'; + return dup; +} + -+void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC) ++void* APC_ALLOC apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC) +{ + return s != NULL ? apc_xmemcpy(s, strlen(s)+1, f TSRMLS_CC) : NULL; +} + -+void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC) ++void* APC_ALLOC apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC) +{ + void* q; + @@ -1339,6 +1348,15 @@ + (filename[1] == '.' && \ + IS_SLASH(filename[2]))))) + ++/* {{{ stupid stringifcation */ ++#if DEFAULT_SLASH == '/' ++ #define DEFAULT_SLASH_STRING "/" ++#elif DEFAULT_SLASH == '\\' ++ #define DEFAULT_SLASH_STRING "\\" ++#else ++ #error "Unknown value for DEFAULT_SLASH" ++#endif ++/* }}} */ + +int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC) +{ @@ -1387,6 +1405,25 @@ + break; + } + } ++ /* in cli mode PHP explicitly checks the cwd, so we should as well */ ++ if(APCG(enable_cli) && !strcmp(sapi_module.name, "cli")) { ++ snprintf(fileinfo->path_buf, sizeof(fileinfo->path_buf), ".%c%s", DEFAULT_SLASH, path_for_open); ++ if (APC_URL_STAT(wrapper, fileinfo->path_buf, &fileinfo->st_buf) == 0) { ++ fileinfo->fullpath = (char*) fileinfo->path_buf; ++ found = 1; ++ } ++ } ++ } else { ++ /* read cwd and try to fake up fullpath */ ++ fileinfo->path_buf[0] = '\0'; ++ if(VCWD_GETCWD(fileinfo->path_buf, sizeof(fileinfo->path_buf))) { ++ strlcat(fileinfo->path_buf, DEFAULT_SLASH_STRING, sizeof(fileinfo->path_buf)); ++ strlcat(fileinfo->path_buf, path_for_open, sizeof(fileinfo->path_buf)); ++ if (APC_URL_STAT(wrapper, fileinfo->path_buf, &fileinfo->st_buf) == 0) { ++ fileinfo->fullpath = (char*) fileinfo->path_buf; ++ return apc_restat(fileinfo TSRMLS_CC); ++ } ++ } + } + + /* check in path of the calling scripts' current working directory */ @@ -1693,14 +1730,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_cache.c -@@ -0,0 +1,1295 @@ +diff -Naur a/ext/apc/apc_cache.c b/ext/apc/apc_cache.c +--- a/ext/apc/apc_cache.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_cache.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,1383 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -1726,13 +1764,15 @@ + + */ + -+/* $Id: apc_cache.c 305771 2010-11-26 12:57:16Z gopalv $ */ ++/* $Id: apc_cache.c 325482 2012-05-01 00:09:36Z rasmus $ */ + +#include "apc_cache.h" +#include "apc_zend.h" +#include "apc_sma.h" +#include "apc_globals.h" +#include "SAPI.h" ++#include "TSRM.h" ++#include "ext/standard/md5.h" + +/* TODO: rehash when load factor exceeds threshold */ + @@ -1745,16 +1785,57 @@ +static void apc_cache_expunge(apc_cache_t* cache, size_t size TSRMLS_DC); + +/* {{{ hash */ -+static unsigned int hash(apc_cache_key_t key) ++static unsigned long hash(apc_cache_key_t key) +{ -+ return (unsigned int)(key.data.file.device + key.data.file.inode); ++ return (unsigned long)(key.data.file.device + key.data.file.inode); +} +/* }}} */ + +/* {{{ string_nhash_8 */ -+#define string_nhash_8(s,len) (unsigned int)(zend_inline_hash_func(s, len)) ++#define string_nhash_8(s,len) (unsigned long)(zend_inline_hash_func((s), len)) +/* }}} */ + ++/* {{{ murmurhash */ ++#if 0 ++static inline unsigned long murmurhash(const char *skey, size_t keylen) ++{ ++ const long m = 0x7fd652ad; ++ const long r = 16; ++ unsigned int h = 0xdeadbeef; ++ ++ while(keylen >= 4) ++ { ++ h += *(unsigned int*)skey; ++ h *= m; ++ h ^= h >> r; ++ ++ skey += 4; ++ keylen -= 4; ++ } ++ ++ switch(keylen) ++ { ++ case 3: ++ h += skey[2] << 16; ++ case 2: ++ h += skey[1] << 8; ++ case 1: ++ h += skey[0]; ++ h *= m; ++ h ^= h >> r; ++ }; ++ ++ h *= m; ++ h ^= h >> 10; ++ h *= m; ++ h ^= h >> 17; ++ ++ return h; ++} ++#endif ++/* }}} */ ++ ++ +/* {{{ make_prime */ +static int const primes[] = { + 257, /* 256 */ @@ -1769,7 +1850,6 @@ + 8209, /* 8192 */ + 9221, /* 9216 */ +10243, /* 10240 */ -+#if 0 +11273, /* 11264 */ +12289, /* 12288 */ +13313, /* 13312 */ @@ -1779,7 +1859,6 @@ +17417, /* 17408 */ +18433, /* 18432 */ +19457, /* 19456 */ -+#endif +0 /* sentinel */ +}; + @@ -1795,26 +1874,26 @@ +/* }}} */ + +/* {{{ make_slot */ -+slot_t* make_slot(apc_cache_key_t key, apc_cache_entry_t* value, slot_t* next, time_t t TSRMLS_DC) ++slot_t* make_slot(apc_cache_key_t *key, apc_cache_entry_t* value, slot_t* next, time_t t TSRMLS_DC) +{ + slot_t* p = apc_pool_alloc(value->pool, sizeof(slot_t)); + + if (!p) return NULL; + -+ if(value->type == APC_CACHE_ENTRY_USER) { -+ char *identifier = (char*) apc_pmemcpy(key.data.user.identifier, key.data.user.identifier_len, value->pool TSRMLS_CC); ++ if(key->type == APC_CACHE_KEY_USER) { ++ char *identifier = (char*) apc_pmemcpy(key->data.user.identifier, key->data.user.identifier_len, value->pool TSRMLS_CC); + if (!identifier) { + return NULL; + } -+ key.data.user.identifier = identifier; -+ } else if(key.type == APC_CACHE_KEY_FPFILE) { -+ char *fullpath = (char*) apc_pstrdup(key.data.fpfile.fullpath, value->pool TSRMLS_CC); ++ key->data.user.identifier = identifier; ++ } else if(key->type == APC_CACHE_KEY_FPFILE) { ++ char *fullpath = (char*) apc_pstrdup(key->data.fpfile.fullpath, value->pool TSRMLS_CC); + if (!fullpath) { + return NULL; + } -+ key.data.fpfile.fullpath = fullpath; ++ key->data.fpfile.fullpath = fullpath; + } -+ p->key = key; ++ p->key = key[0]; + p->value = value; + p->next = next; + p->num_hits = 0; @@ -1839,7 +1918,7 @@ + *slot = (*slot)->next; + + cache->header->mem_size -= dead->value->mem_size; -+ cache->header->num_entries--; ++ CACHE_FAST_DEC(cache, cache->header->num_entries); + if (dead->value->ref_count <= 0) { + free_slot(dead TSRMLS_CC); + } @@ -1878,11 +1957,11 @@ + if (dead->value->ref_count > 0) { + switch(dead->value->type) { + case APC_CACHE_ENTRY_FILE: -+ apc_warning("GC cache entry '%s' (dev=%d ino=%d) was on gc-list for %d seconds" TSRMLS_CC, ++ apc_debug("GC cache entry '%s' (dev=%d ino=%d) was on gc-list for %d seconds" TSRMLS_CC, + dead->value->data.file.filename, dead->key.data.file.device, dead->key.data.file.inode, gc_sec); + break; + case APC_CACHE_ENTRY_USER: -+ apc_warning("GC cache entry '%s'was on gc-list for %d seconds" TSRMLS_CC, dead->value->data.user.info, gc_sec); ++ apc_debug("GC cache entry '%s' was on gc-list for %d seconds" TSRMLS_CC, dead->value->data.user.info, gc_sec); + break; + } + } @@ -1939,6 +2018,7 @@ + cache->shmaddr = apc_sma_malloc(cache_size TSRMLS_CC); + if(!cache->shmaddr) { + apc_error("Unable to allocate shared memory for cache structures. (Perhaps your shared memory size isn't large enough?). " TSRMLS_CC); ++ return NULL; + } + memset(cache->shmaddr, 0, cache_size); + @@ -1970,7 +2050,7 @@ +void apc_cache_destroy(apc_cache_t* cache TSRMLS_DC) +{ + DESTROY_LOCK(cache->header->lock); -+#ifdef NONBLOCKING_LOCK_AVAILABLE ++#if NONBLOCKING_LOCK_AVAILABLE + DESTROY_LOCK(cache->header->wrlock); +#endif + apc_efree(cache TSRMLS_CC); @@ -2022,13 +2102,14 @@ + * we run out of space. + */ + CACHE_SAFE_LOCK(cache); ++ process_pending_removals(cache TSRMLS_CC); + if (apc_sma_get_avail_mem() > (size_t)(APCG(shm_size)/2)) { + /* probably a queued up expunge, we don't need to do this */ + CACHE_SAFE_UNLOCK(cache); + return; + } + cache->header->busy = 1; -+ cache->header->expunges++; ++ CACHE_FAST_INC(cache, cache->header->expunges); +clear_all: + for (i = 0; i < cache->num_slots; i++) { + slot_t* p = cache->slots[i]; @@ -2052,13 +2133,14 @@ + */ + + CACHE_SAFE_LOCK(cache); ++ process_pending_removals(cache TSRMLS_CC); + if (apc_sma_get_avail_mem() > (size_t)(APCG(shm_size)/2)) { + /* probably a queued up expunge, we don't need to do this */ + CACHE_SAFE_UNLOCK(cache); + return; + } + cache->header->busy = 1; -+ cache->header->expunges++; ++ CACHE_FAST_INC(cache, cache->header->expunges); + for (i = 0; i < cache->num_slots; i++) { + p = &cache->slots[i]; + while(*p) { @@ -2115,8 +2197,7 @@ + + process_pending_removals(cache TSRMLS_CC); + -+ if(key.type == APC_CACHE_KEY_FILE) slot = &cache->slots[hash(key) % cache->num_slots]; -+ else slot = &cache->slots[string_nhash_8(key.data.fpfile.fullpath, key.data.fpfile.fullpath_len) % cache->num_slots]; ++ slot = &cache->slots[key.h % cache->num_slots]; + + while(*slot) { + if(key.type == (*slot)->key.type) { @@ -2133,7 +2214,8 @@ + continue; + } + } else { /* APC_CACHE_KEY_FPFILE */ -+ if(!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { ++ if((key.h == (*slot)->key.h) && ++ !memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { + /* Hrm.. it's already here, remove it and insert new one */ + remove_slot(cache, slot TSRMLS_CC); + break; @@ -2146,14 +2228,14 @@ + slot = &(*slot)->next; + } + -+ if ((*slot = make_slot(key, value, *slot, t TSRMLS_CC)) == NULL) { ++ if ((*slot = make_slot(&key, value, *slot, t TSRMLS_CC)) == NULL) { + return -1; + } + + value->mem_size = ctxt->pool->size; + cache->header->mem_size += ctxt->pool->size; -+ cache->header->num_entries++; -+ cache->header->num_inserts++; ++ CACHE_FAST_INC(cache, cache->header->num_entries); ++ CACHE_FAST_INC(cache, cache->header->num_inserts); + + return 1; +} @@ -2195,7 +2277,6 @@ +{ + slot_t** slot; + unsigned int keylen = key.data.user.identifier_len; -+ unsigned int h = string_nhash_8(key.data.user.identifier, keylen); + apc_keyid_t *lastkey = &cache->header->lastkey; + + if (!value) { @@ -2207,9 +2288,8 @@ + return 0; + } + -+ if(apc_cache_is_last_key(cache, &key, h, t TSRMLS_CC)) { ++ if(apc_cache_is_last_key(cache, &key, t TSRMLS_CC)) { + /* potential cache slam */ -+ printf("Last key warning for it!"); + return 0; + } + @@ -2217,7 +2297,7 @@ + + memset(lastkey, 0, sizeof(apc_keyid_t)); + -+ lastkey->h = h; ++ lastkey->h = key.h; + lastkey->keylen = keylen; + lastkey->mtime = t; +#ifdef ZTS @@ -2232,10 +2312,10 @@ + + process_pending_removals(cache TSRMLS_CC); + -+ slot = &cache->slots[h % cache->num_slots]; ++ slot = &cache->slots[key.h % cache->num_slots]; + + while (*slot) { -+ if (((*slot)->key.data.user.identifier_len == key.data.user.identifier_len) && ++ if (((*slot)->key.h == key.h) && + (!memcmp((*slot)->key.data.user.identifier, key.data.user.identifier, keylen))) { + /* + * At this point we have found the user cache entry. If we are doing @@ -2266,15 +2346,15 @@ + slot = &(*slot)->next; + } + -+ if ((*slot = make_slot(key, value, *slot, t TSRMLS_CC)) == NULL) { ++ if ((*slot = make_slot(&key, value, *slot, t TSRMLS_CC)) == NULL) { + goto fail; + } + + value->mem_size = ctxt->pool->size; + cache->header->mem_size += ctxt->pool->size; + -+ cache->header->num_entries++; -+ cache->header->num_inserts++; ++ CACHE_FAST_INC(cache, cache->header->num_entries); ++ CACHE_FAST_INC(cache, cache->header->num_inserts); + + CACHE_UNLOCK(cache); + @@ -2293,47 +2373,54 @@ + slot_t** slot; + volatile slot_t* retval = NULL; + -+ CACHE_LOCK(cache); ++ CACHE_RDLOCK(cache); + if(key.type == APC_CACHE_KEY_FILE) slot = &cache->slots[hash(key) % cache->num_slots]; -+ else slot = &cache->slots[string_nhash_8(key.data.fpfile.fullpath, key.data.fpfile.fullpath_len) % cache->num_slots]; ++ else slot = &cache->slots[key.h % cache->num_slots]; + + while (*slot) { + if(key.type == (*slot)->key.type) { + if(key.type == APC_CACHE_KEY_FILE) { + if(key_equals((*slot)->key.data.file, key.data.file)) { + if((*slot)->key.mtime != key.mtime) { ++ #if (USE_READ_LOCKS == 0) ++ /* this is merely a memory-friendly optimization, if we do have a write-lock ++ * might as well move this to the deleted_list right-away. Otherwise an insert ++ * of the same key wil do it (or an expunge, *eventually*). ++ */ + remove_slot(cache, slot TSRMLS_CC); -+ cache->header->num_misses++; -+ CACHE_UNLOCK(cache); ++ #endif ++ CACHE_SAFE_INC(cache, cache->header->num_misses); ++ CACHE_RDUNLOCK(cache); + return NULL; + } -+ (*slot)->num_hits++; -+ (*slot)->value->ref_count++; ++ CACHE_SAFE_INC(cache, (*slot)->num_hits); ++ CACHE_SAFE_INC(cache, (*slot)->value->ref_count); + (*slot)->access_time = t; + prevent_garbage_collection((*slot)->value); -+ cache->header->num_hits++; ++ CACHE_FAST_INC(cache, cache->header->num_hits); + retval = *slot; -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return (slot_t*)retval; + } + } else { /* APC_CACHE_KEY_FPFILE */ -+ if(!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { ++ if(((*slot)->key.h == key.h) && ++ !memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { + /* TTL Check ? */ -+ (*slot)->num_hits++; -+ (*slot)->value->ref_count++; ++ CACHE_SAFE_INC(cache, (*slot)->num_hits); ++ CACHE_SAFE_INC(cache, (*slot)->value->ref_count); + (*slot)->access_time = t; + prevent_garbage_collection((*slot)->value); -+ cache->header->num_hits++; ++ CACHE_FAST_INC(cache, cache->header->num_hits); + retval = *slot; -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return (slot_t*)retval; + } + } + } + slot = &(*slot)->next; + } -+ cache->header->num_misses++; -+ CACHE_UNLOCK(cache); ++ CACHE_FAST_INC(cache, cache->header->num_misses); ++ CACHE_RDUNLOCK(cache); + return NULL; +} +/* }}} */ @@ -2342,6 +2429,7 @@ +apc_cache_entry_t* apc_cache_find(apc_cache_t* cache, apc_cache_key_t key, time_t t TSRMLS_DC) +{ + slot_t * slot = apc_cache_find_slot(cache, key, t TSRMLS_CC); ++ apc_debug("apc_cache_find [%i]\n" TSRMLS_CC, key.h); + return (slot) ? slot->value : NULL; +} +/* }}} */ @@ -2351,6 +2439,7 @@ +{ + slot_t** slot; + volatile apc_cache_entry_t* value = NULL; ++ unsigned long h; + + if(apc_cache_busy(cache)) + { @@ -2358,34 +2447,43 @@ + return NULL; + } + -+ CACHE_LOCK(cache); ++ CACHE_RDLOCK(cache); + -+ slot = &cache->slots[string_nhash_8(strkey, keylen) % cache->num_slots]; ++ h = string_nhash_8(strkey, keylen); ++ ++ slot = &cache->slots[h % cache->num_slots]; + + while (*slot) { -+ if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { ++ if ((h == (*slot)->key.h) && ++ !memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { + /* Check to make sure this entry isn't expired by a hard TTL */ + if((*slot)->value->data.user.ttl && (time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t) { ++ #if (USE_READ_LOCKS == 0) ++ /* this is merely a memory-friendly optimization, if we do have a write-lock ++ * might as well move this to the deleted_list right-away. Otherwise an insert ++ * of the same key wil do it (or an expunge, *eventually*). ++ */ + remove_slot(cache, slot TSRMLS_CC); -+ cache->header->num_misses++; -+ CACHE_UNLOCK(cache); ++ #endif ++ CACHE_FAST_INC(cache, cache->header->num_misses); ++ CACHE_RDUNLOCK(cache); + return NULL; + } + /* Otherwise we are fine, increase counters and return the cache entry */ -+ (*slot)->num_hits++; -+ (*slot)->value->ref_count++; ++ CACHE_SAFE_INC(cache, (*slot)->num_hits); ++ CACHE_SAFE_INC(cache, (*slot)->value->ref_count); + (*slot)->access_time = t; + -+ cache->header->num_hits++; ++ CACHE_FAST_INC(cache, cache->header->num_hits); + value = (*slot)->value; -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return (apc_cache_entry_t*)value; + } + slot = &(*slot)->next; + } + -+ cache->header->num_misses++; -+ CACHE_UNLOCK(cache); ++ CACHE_FAST_INC(cache, cache->header->num_misses); ++ CACHE_RDUNLOCK(cache); + return NULL; +} +/* }}} */ @@ -2395,6 +2493,7 @@ +{ + slot_t** slot; + volatile apc_cache_entry_t* value = NULL; ++ unsigned long h; + + if(apc_cache_busy(cache)) + { @@ -2402,12 +2501,15 @@ + return NULL; + } + -+ CACHE_LOCK(cache); ++ CACHE_RDLOCK(cache); + -+ slot = &cache->slots[string_nhash_8(strkey, keylen) % cache->num_slots]; ++ h = string_nhash_8(strkey, keylen); ++ ++ slot = &cache->slots[h % cache->num_slots]; + + while (*slot) { -+ if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { ++ if ((h == (*slot)->key.h) && ++ !memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { + /* Check to make sure this entry isn't expired by a hard TTL */ + if((*slot)->value->data.user.ttl && (time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t) { + CACHE_UNLOCK(cache); @@ -2415,12 +2517,12 @@ + } + /* Return the cache entry ptr */ + value = (*slot)->value; -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return (apc_cache_entry_t*)value; + } + slot = &(*slot)->next; + } -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return NULL; +} +/* }}} */ @@ -2430,6 +2532,7 @@ +{ + slot_t** slot; + int retval; ++ unsigned long h; + + if(apc_cache_busy(cache)) + { @@ -2439,12 +2542,32 @@ + + CACHE_LOCK(cache); + -+ slot = &cache->slots[string_nhash_8(strkey, keylen) % cache->num_slots]; ++ h = string_nhash_8(strkey, keylen); ++ slot = &cache->slots[h % cache->num_slots]; + + while (*slot) { -+ if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { -+ retval = updater(cache, (*slot)->value, data); -+ (*slot)->key.mtime = apc_time(); ++ if ((h == (*slot)->key.h) && ++ !memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { ++ switch(Z_TYPE_P((*slot)->value->data.user.val) & ~IS_CONSTANT_INDEX) { ++ case IS_ARRAY: ++ case IS_CONSTANT_ARRAY: ++ case IS_OBJECT: ++ { ++ if(APCG(serializer)) { ++ retval = 0; ++ break; ++ } else { ++ /* fall through */ ++ } ++ } ++ /* fall through */ ++ default: ++ { ++ retval = updater(cache, (*slot)->value, data); ++ (*slot)->key.mtime = apc_time(); ++ } ++ break; ++ } + CACHE_UNLOCK(cache); + return retval; + } @@ -2459,13 +2582,17 @@ +int apc_cache_user_delete(apc_cache_t* cache, char *strkey, int keylen TSRMLS_DC) +{ + slot_t** slot; ++ unsigned long h; + + CACHE_LOCK(cache); + -+ slot = &cache->slots[string_nhash_8(strkey, keylen) % cache->num_slots]; ++ h = string_nhash_8(strkey, keylen); ++ ++ slot = &cache->slots[h % cache->num_slots]; + + while (*slot) { -+ if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { ++ if ((h == (*slot)->key.h) && ++ !memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { + remove_slot(cache, slot TSRMLS_CC); + CACHE_UNLOCK(cache); + return 1; @@ -2496,7 +2623,7 @@ + CACHE_LOCK(cache); + + if(key.type == APC_CACHE_KEY_FILE) slot = &cache->slots[hash(key) % cache->num_slots]; -+ else slot = &cache->slots[string_nhash_8(key.data.fpfile.fullpath, key.data.fpfile.fullpath_len) % cache->num_slots]; ++ else slot = &cache->slots[key.h % cache->num_slots]; + + while(*slot) { + if(key.type == (*slot)->key.type) { @@ -2507,7 +2634,7 @@ + return 1; + } + } else { /* APC_CACHE_KEY_FPFILE */ -+ if(((*slot)->key.data.fpfile.fullpath_len == key.data.fpfile.fullpath_len) && ++ if(((*slot)->key.h == key.h) && + (!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1))) { + remove_slot(cache, slot TSRMLS_CC); + CACHE_UNLOCK(cache); @@ -2529,9 +2656,7 @@ +/* {{{ apc_cache_release */ +void apc_cache_release(apc_cache_t* cache, apc_cache_entry_t* entry TSRMLS_DC) +{ -+ CACHE_LOCK(cache); -+ entry->ref_count--; -+ CACHE_UNLOCK(cache); ++ CACHE_SAFE_DEC(cache, entry->ref_count); +} +/* }}} */ + @@ -2555,9 +2680,10 @@ + + len = strlen(filename); + if(APCG(fpstat)==0) { -+ if(IS_ABSOLUTE_PATH(filename,len)) { ++ if(IS_ABSOLUTE_PATH(filename,len) || strstr(filename, "://")) { + key->data.fpfile.fullpath = filename; + key->data.fpfile.fullpath_len = len; ++ key->h = string_nhash_8(key->data.fpfile.fullpath, key->data.fpfile.fullpath_len); + key->mtime = t; + key->type = APC_CACHE_KEY_FPFILE; + goto success; @@ -2577,6 +2703,7 @@ + + key->data.fpfile.fullpath = APCG(canon_path); + key->data.fpfile.fullpath_len = strlen(APCG(canon_path)); ++ key->h = string_nhash_8(key->data.fpfile.fullpath, key->data.fpfile.fullpath_len); + key->mtime = t; + key->type = APC_CACHE_KEY_FPFILE; + goto success; @@ -2625,6 +2752,7 @@ + + key->data.file.device = fileinfo->st_buf.sb.st_dev; + key->data.file.inode = fileinfo->st_buf.sb.st_ino; ++ key->h = (unsigned long) key->data.file.device + (unsigned long) key->data.file.inode; + + /* + * If working with content management systems that like to munge the mtime, @@ -2672,6 +2800,7 @@ + + key->data.user.identifier = identifier; + key->data.user.identifier_len = identifier_len; ++ key->h = string_nhash_8(key->data.user.identifier, key->data.user.identifier_len); + key->mtime = t; + key->type = APC_CACHE_KEY_USER; + return 1; @@ -2776,152 +2905,151 @@ +} +/* }}} */ + -+/* {{{ apc_cache_info */ -+apc_cache_info_t* apc_cache_info(apc_cache_t* cache, zend_bool limited TSRMLS_DC) ++/* {{{ */ ++static zval* apc_cache_link_info(apc_cache_t *cache, slot_t* p TSRMLS_DC) +{ -+ apc_cache_info_t* info; ++ zval *link = NULL; ++ char md5str[33]; ++ ++ ALLOC_INIT_ZVAL(link); ++ ++ if(!link) { ++ return NULL; ++ } ++ ++ array_init(link); ++ ++ if(p->value->type == APC_CACHE_ENTRY_FILE) { ++ add_assoc_string(link, "type", "file", 1); ++ if(p->key.type == APC_CACHE_KEY_FILE) { ++ ++ #ifdef PHP_WIN32 ++ { ++ char buf[20]; ++ sprintf(buf, "%I64d", p->key.data.file.device); ++ add_assoc_string(link, "device", buf, 1); ++ ++ sprintf(buf, "%I64d", p->key.data.file.inode); ++ add_assoc_string(link, "inode", buf, 1); ++ } ++ #else ++ add_assoc_long(link, "device", p->key.data.file.device); ++ add_assoc_long(link, "inode", p->key.data.file.inode); ++ #endif ++ ++ add_assoc_string(link, "filename", p->value->data.file.filename, 1); ++ } else { /* This is a no-stat fullpath file entry */ ++ add_assoc_long(link, "device", 0); ++ add_assoc_long(link, "inode", 0); ++ add_assoc_string(link, "filename", (char*)p->key.data.fpfile.fullpath, 1); ++ } ++ if (APCG(file_md5)) { ++ make_digest(md5str, p->key.md5); ++ add_assoc_string(link, "md5", md5str, 1); ++ } ++ } else if(p->value->type == APC_CACHE_ENTRY_USER) { ++ add_assoc_stringl(link, "info", p->value->data.user.info, p->value->data.user.info_len-1, 1); ++ add_assoc_long(link, "ttl", (long)p->value->data.user.ttl); ++ add_assoc_string(link, "type", "user", 1); ++ } ++ ++ add_assoc_double(link, "num_hits", (double)p->num_hits); ++ add_assoc_long(link, "mtime", p->key.mtime); ++ add_assoc_long(link, "creation_time", p->creation_time); ++ add_assoc_long(link, "deletion_time", p->deletion_time); ++ add_assoc_long(link, "access_time", p->access_time); ++ add_assoc_long(link, "ref_count", p->value->ref_count); ++ add_assoc_long(link, "mem_size", p->value->mem_size); ++ ++ return link; ++} ++/* }}} */ ++ ++/* {{{ apc_cache_info */ ++zval* apc_cache_info(apc_cache_t* cache, zend_bool limited TSRMLS_DC) ++{ ++ zval *info = NULL; ++ zval *list = NULL; ++ zval *deleted_list = NULL; ++ zval *slots = NULL; + slot_t* p; -+ int i; ++ int i, j; + + if(!cache) return NULL; + -+ CACHE_LOCK(cache); ++ CACHE_RDLOCK(cache); ++ ++ ALLOC_INIT_ZVAL(info); + -+ info = (apc_cache_info_t*) apc_php_malloc(sizeof(apc_cache_info_t) TSRMLS_CC); + if(!info) { -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return NULL; + } -+ info->num_slots = cache->num_slots; -+ info->ttl = cache->ttl; -+ info->num_hits = cache->header->num_hits; -+ info->num_misses = cache->header->num_misses; -+ info->list = NULL; -+ info->deleted_list = NULL; -+ info->start_time = cache->header->start_time; -+ info->expunges = cache->header->expunges; -+ info->mem_size = cache->header->mem_size; -+ info->num_entries = cache->header->num_entries; -+ info->num_inserts = cache->header->num_inserts; ++ ++ array_init(info); ++ add_assoc_long(info, "num_slots", cache->num_slots); ++ add_assoc_long(info, "ttl", cache->ttl); ++ ++ add_assoc_double(info, "num_hits", (double)cache->header->num_hits); ++ add_assoc_double(info, "num_misses", (double)cache->header->num_misses); ++ add_assoc_double(info, "num_inserts", (double)cache->header->num_inserts); ++ add_assoc_double(info, "expunges", (double)cache->header->expunges); ++ ++ add_assoc_long(info, "start_time", cache->header->start_time); ++ add_assoc_double(info, "mem_size", (double)cache->header->mem_size); ++ add_assoc_long(info, "num_entries", cache->header->num_entries); ++#ifdef MULTIPART_EVENT_FORMDATA ++ add_assoc_long(info, "file_upload_progress", 1); ++#else ++ add_assoc_long(info, "file_upload_progress", 0); ++#endif ++#if APC_MMAP ++ add_assoc_stringl(info, "memory_type", "mmap", sizeof("mmap")-1, 1); ++#else ++ add_assoc_stringl(info, "memory_type", "IPC shared", sizeof("IPC shared")-1, 1); ++#endif ++ add_assoc_stringl(info, "locking_type", APC_LOCK_TYPE, sizeof(APC_LOCK_TYPE)-1, 1); + + if(!limited) { + /* For each hashtable slot */ -+ for (i = 0; i < info->num_slots; i++) { -+ p = cache->slots[i]; -+ for (; p != NULL; p = p->next) { -+ apc_cache_link_t* link = (apc_cache_link_t*) apc_php_malloc(sizeof(apc_cache_link_t) TSRMLS_CC); ++ ALLOC_INIT_ZVAL(list); ++ array_init(list); + -+ if(p->value->type == APC_CACHE_ENTRY_FILE) { -+ if(p->key.type == APC_CACHE_KEY_FILE) { -+ link->data.file.device = p->key.data.file.device; -+ link->data.file.inode = p->key.data.file.inode; -+ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_php_malloc TSRMLS_CC); -+ } else { /* This is a no-stat fullpath file entry */ -+ link->data.file.device = 0; -+ link->data.file.inode = 0; -+ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_php_malloc TSRMLS_CC); -+ } -+ link->type = APC_CACHE_ENTRY_FILE; -+ if (APCG(file_md5)) { -+ link->data.file.md5 = emalloc(sizeof(p->key.md5)); -+ memcpy(link->data.file.md5, p->key.md5, 16); -+ } else { -+ link->data.file.md5 = NULL; -+ } -+ } else if(p->value->type == APC_CACHE_ENTRY_USER) { -+ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_php_malloc TSRMLS_CC); -+ link->data.user.ttl = p->value->data.user.ttl; -+ link->type = APC_CACHE_ENTRY_USER; -+ } -+ link->num_hits = p->num_hits; -+ link->mtime = p->key.mtime; -+ link->creation_time = p->creation_time; -+ link->deletion_time = p->deletion_time; -+ link->access_time = p->access_time; -+ link->ref_count = p->value->ref_count; -+ link->mem_size = p->value->mem_size; -+ link->next = info->list; -+ info->list = link; ++ ALLOC_INIT_ZVAL(slots); ++ array_init(slots); ++ ++ for (i = 0; i < cache->num_slots; i++) { ++ p = cache->slots[i]; ++ j = 0; ++ for (; p != NULL; p = p->next) { ++ zval *link = apc_cache_link_info(cache, p TSRMLS_CC); ++ add_next_index_zval(list, link); ++ j++; ++ } ++ if(j != 0) { ++ add_index_long(slots, (ulong)i, j); + } + } + + /* For each slot pending deletion */ ++ ALLOC_INIT_ZVAL(deleted_list); ++ array_init(deleted_list); ++ + for (p = cache->header->deleted_list; p != NULL; p = p->next) { -+ apc_cache_link_t* link = (apc_cache_link_t*) apc_php_malloc(sizeof(apc_cache_link_t) TSRMLS_CC); -+ -+ if(p->value->type == APC_CACHE_ENTRY_FILE) { -+ if(p->key.type == APC_CACHE_KEY_FILE) { -+ link->data.file.device = p->key.data.file.device; -+ link->data.file.inode = p->key.data.file.inode; -+ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_php_malloc TSRMLS_CC); -+ } else { /* This is a no-stat fullpath file entry */ -+ link->data.file.device = 0; -+ link->data.file.inode = 0; -+ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_php_malloc TSRMLS_CC); -+ } -+ link->type = APC_CACHE_ENTRY_FILE; -+ if (APCG(file_md5)) { -+ link->data.file.md5 = emalloc(sizeof(p->key.md5)); -+ memcpy(link->data.file.md5, p->key.md5, 16); -+ } else { -+ link->data.file.md5 = NULL; -+ } -+ } else if(p->value->type == APC_CACHE_ENTRY_USER) { -+ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_php_malloc TSRMLS_CC); -+ link->data.user.ttl = p->value->data.user.ttl; -+ link->type = APC_CACHE_ENTRY_USER; -+ } -+ link->num_hits = p->num_hits; -+ link->mtime = p->key.mtime; -+ link->creation_time = p->creation_time; -+ link->deletion_time = p->deletion_time; -+ link->access_time = p->access_time; -+ link->ref_count = p->value->ref_count; -+ link->mem_size = p->value->mem_size; -+ link->next = info->deleted_list; -+ info->deleted_list = link; ++ zval *link = apc_cache_link_info(cache, p TSRMLS_CC); ++ add_next_index_zval(deleted_list, link); + } ++ ++ add_assoc_zval(info, "cache_list", list); ++ add_assoc_zval(info, "deleted_list", deleted_list); ++ add_assoc_zval(info, "slot_distribution", slots); + } + -+ CACHE_UNLOCK(cache); ++ CACHE_RDUNLOCK(cache); + return info; +} +/* }}} */ + -+/* {{{ apc_cache_free_info */ -+void apc_cache_free_info(apc_cache_info_t* info TSRMLS_DC) -+{ -+ apc_cache_link_t* p = info->list; -+ apc_cache_link_t* q = NULL; -+ while (p != NULL) { -+ q = p; -+ p = p->next; -+ if(q->type == APC_CACHE_ENTRY_FILE) { -+ if(q->data.file.md5) { -+ efree(q->data.file.md5); -+ } -+ apc_php_free(q->data.file.filename TSRMLS_CC); -+ } -+ else if(q->type == APC_CACHE_ENTRY_USER) apc_php_free(q->data.user.info TSRMLS_CC); -+ apc_php_free(q TSRMLS_CC); -+ } -+ p = info->deleted_list; -+ while (p != NULL) { -+ q = p; -+ p = p->next; -+ if(q->type == APC_CACHE_ENTRY_FILE) { -+ if(q->data.file.md5) { -+ efree(q->data.file.md5); -+ } -+ apc_php_free(q->data.file.filename TSRMLS_CC); -+ } -+ else if(q->type == APC_CACHE_ENTRY_USER) apc_php_free(q->data.user.info TSRMLS_CC); -+ apc_php_free(q TSRMLS_CC); -+ } -+ apc_php_free(info TSRMLS_CC); -+} -+/* }}} */ -+ +/* {{{ apc_cache_unlock */ +void apc_cache_unlock(apc_cache_t* cache TSRMLS_DC) +{ @@ -2937,7 +3065,7 @@ +/* }}} */ + +/* {{{ apc_cache_is_last_key */ -+zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, unsigned int h, time_t t TSRMLS_DC) ++zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t TSRMLS_DC) +{ + apc_keyid_t *lastkey = &cache->header->lastkey; + unsigned int keylen = key->data.user.identifier_len; @@ -2950,14 +3078,12 @@ +#endif + + -+ if(!h) h = string_nhash_8(key->data.user.identifier, keylen); -+ + /* unlocked reads, but we're not shooting for 100% success with this */ -+ if(lastkey->h == h && keylen == lastkey->keylen) { ++ if(lastkey->h == key->h && keylen == lastkey->keylen) { + if(lastkey->mtime == t && FROM_DIFFERENT_THREAD(lastkey)) { + /* potential cache slam */ + if(APCG(slam_defense)) { -+ apc_warning("Potential cache slam averted for key '%s'" TSRMLS_CC, key->data.user.identifier); ++ apc_debug("Potential cache slam averted for key '%s'" TSRMLS_CC, key->data.user.identifier); + return 1; + } + } @@ -2991,14 +3117,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_cache.h -@@ -0,0 +1,403 @@ +diff -Naur a/ext/apc/apc_cache.h b/ext/apc/apc_cache.h +--- a/ext/apc/apc_cache.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_cache.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,371 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -3022,7 +3149,7 @@ + + */ + -+/* $Id: apc_cache.h 305258 2010-11-10 19:02:06Z gopalv $ */ ++/* $Id: apc_cache.h 324329 2012-03-18 15:29:37Z mike $ */ + +#ifndef APC_CACHE_H +#define APC_CACHE_H @@ -3059,6 +3186,23 @@ +#define CACHE_UNLOCK(cache) { UNLOCK(cache->header->lock); cache->has_lock = 0; } +#define CACHE_SAFE_LOCK(cache) { if ((++cache->has_lock) == 1) LOCK(cache->header->lock); } +#define CACHE_SAFE_UNLOCK(cache) { if ((--cache->has_lock) == 0) UNLOCK(cache->header->lock); } ++ ++#if (RDLOCK_AVAILABLE == 1) && defined(HAVE_ATOMIC_OPERATIONS) ++#define USE_READ_LOCKS 1 ++#define CACHE_RDLOCK(cache) { RDLOCK(cache->header->lock); cache->has_lock = 0; } ++#define CACHE_RDUNLOCK(cache) { RDUNLOCK(cache->header->lock); cache->has_lock = 0; } ++#define CACHE_SAFE_INC(cache, obj) { ATOMIC_INC(obj); } ++#define CACHE_SAFE_DEC(cache, obj) { ATOMIC_DEC(obj); } ++#else ++#define USE_READ_LOCKS 0 ++#define CACHE_RDLOCK(cache) { LOCK(cache->header->lock); cache->has_lock = 1; } ++#define CACHE_RDUNLOCK(cache) { UNLOCK(cache->header->lock); cache->has_lock = 0; } ++#define CACHE_SAFE_INC(cache, obj) { CACHE_SAFE_LOCK(cache); obj++; CACHE_SAFE_UNLOCK(cache);} ++#define CACHE_SAFE_DEC(cache, obj) { CACHE_SAFE_LOCK(cache); obj--; CACHE_SAFE_UNLOCK(cache);} ++#endif ++ ++#define CACHE_FAST_INC(cache, obj) { obj++; } ++#define CACHE_FAST_DEC(cache, obj) { obj--; } +/* }}} */ + +/* {{{ struct definition: apc_cache_key_t */ @@ -3083,6 +3227,7 @@ +typedef struct apc_cache_key_t apc_cache_key_t; +struct apc_cache_key_t { + apc_cache_key_data_t data; ++ unsigned long h; /* pre-computed hash value */ + time_t mtime; /* the mtime of this cached entry */ + unsigned char type; + unsigned char md5[16]; /* md5 hash of the source file */ @@ -3262,10 +3407,10 @@ + apc_function_t* functions, + apc_class_t* classes, + apc_context_t* ctxt -+ TSRMLS_DC); ++ TSRMLS_DC); + + -+zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array_pp, apc_cache_entry_t** cache_entry_pp TSRMLS_DC); ++zend_bool apc_compile_cache_entry(apc_cache_key_t *key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array_pp, apc_cache_entry_t** cache_entry_pp TSRMLS_DC); + +/* + * apc_cache_make_user_entry creates an apc_cache_entry_t object given an info string @@ -3275,55 +3420,6 @@ + +extern int apc_cache_make_user_key(apc_cache_key_t* key, char* identifier, int identifier_len, const time_t t); + -+/* {{{ struct definition: apc_cache_link_data_t */ -+typedef union _apc_cache_link_data_t { -+ struct { -+ char *filename; -+ apc_ino_t device; -+ apc_dev_t inode; -+ unsigned char *md5; -+ } file; -+ struct { -+ char *info; -+ unsigned int ttl; -+ } user; -+} apc_cache_link_data_t; -+/* }}} */ -+ -+/* {{{ struct definition: apc_cache_link_t */ -+typedef struct apc_cache_link_t apc_cache_link_t; -+struct apc_cache_link_t { -+ apc_cache_link_data_t data; -+ unsigned char type; -+ unsigned long num_hits; -+ time_t mtime; -+ time_t creation_time; -+ time_t deletion_time; -+ time_t access_time; -+ int ref_count; -+ size_t mem_size; -+ apc_cache_link_t* next; -+}; -+/* }}} */ -+ -+ -+/* {{{ struct definition: apc_cache_info_t */ -+typedef struct apc_cache_info_t apc_cache_info_t; -+struct apc_cache_info_t { -+ int num_slots; -+ unsigned long num_hits; -+ unsigned long num_misses; -+ unsigned long num_inserts; -+ unsigned long expunges; -+ int ttl; -+ apc_cache_link_t* list; -+ apc_cache_link_t* deleted_list; -+ time_t start_time; -+ int num_entries; -+ size_t mem_size; -+}; -+/* }}} */ -+ +/* {{{ struct definition: slot_t */ +typedef struct slot_t slot_t; +struct slot_t { @@ -3371,13 +3467,12 @@ +}; +/* }}} */ + -+extern apc_cache_info_t* apc_cache_info(T cache, zend_bool limited TSRMLS_DC); -+extern void apc_cache_free_info(apc_cache_info_t* info TSRMLS_DC); ++extern zval* apc_cache_info(T cache, zend_bool limited TSRMLS_DC); +extern void apc_cache_unlock(apc_cache_t* cache TSRMLS_DC); +extern zend_bool apc_cache_busy(apc_cache_t* cache); +extern zend_bool apc_cache_write_lock(apc_cache_t* cache TSRMLS_DC); +extern void apc_cache_write_unlock(apc_cache_t* cache TSRMLS_DC); -+extern zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, unsigned int h, time_t t TSRMLS_DC); ++extern zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t TSRMLS_DC); + +/* used by apc_rfc1867 to update data in-place - not to be used elsewhere */ + @@ -3397,14 +3492,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_compile.c -@@ -0,0 +1,2102 @@ +diff -Naur a/ext/apc/apc_compile.c b/ext/apc/apc_compile.c +--- a/ext/apc/apc_compile.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_compile.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,2164 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -3430,19 +3526,16 @@ + + */ + -+/* $Id: apc_compile.c 303796 2010-09-27 17:14:18Z gopalv $ */ ++/* $Id: apc_compile.c 326703 2012-07-19 17:06:12Z rasmus $ */ + +#include "apc_compile.h" +#include "apc_globals.h" +#include "apc_zend.h" ++#include "apc_php.h" +#include "apc_string.h" +#include "ext/standard/php_var.h" +#include "ext/standard/php_smart_str.h" + -+#ifndef IS_CONSTANT_TYPE_MASK -+#define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) -+#endif -+ +typedef void* (*ht_copy_fun_t)(void*, void*, apc_context_t* TSRMLS_DC); +//typedef void (*ht_free_fun_t)(void*, apc_context_t*); +typedef int (*ht_check_copy_fun_t)(Bucket*, va_list); @@ -3462,7 +3555,9 @@ + */ +static zval** my_copy_zval_ptr(zval**, const zval**, apc_context_t* TSRMLS_DC); +static zval* my_copy_zval(zval*, const zval*, apc_context_t* TSRMLS_DC); ++#ifndef ZEND_ENGINE_2_4 +static znode* my_copy_znode(znode*, znode*, apc_context_t* TSRMLS_DC); ++#endif +static zend_op* my_copy_zend_op(zend_op*, zend_op*, apc_context_t* TSRMLS_DC); +static zend_function* my_copy_function(zend_function*, zend_function*, apc_context_t* TSRMLS_DC); +static zend_function_entry* my_copy_function_entry(zend_function_entry*, const zend_function_entry*, apc_context_t* TSRMLS_DC); @@ -3495,13 +3590,49 @@ + * defined/overridden in the 'current' class and not inherited. + */ +static int my_check_copy_function(Bucket* src, va_list args); -+static int my_check_copy_default_property(Bucket* p, va_list args); +static int my_check_copy_property_info(Bucket* src, va_list args); ++#ifndef ZEND_ENGINE_2_4 ++static int my_check_copy_default_property(Bucket* p, va_list args); +static int my_check_copy_static_member(Bucket* src, va_list args); ++#endif +static int my_check_copy_constant(Bucket* src, va_list args); + +/* }}} */ + ++/* {{{ apc php serializers */ ++int APC_SERIALIZER_NAME(php) (APC_SERIALIZER_ARGS) ++{ ++ smart_str strbuf = {0}; ++ php_serialize_data_t var_hash; ++ PHP_VAR_SERIALIZE_INIT(var_hash); ++ php_var_serialize(&strbuf, (zval**)&value, &var_hash TSRMLS_CC); ++ PHP_VAR_SERIALIZE_DESTROY(var_hash); ++ if(strbuf.c) { ++ *buf = (unsigned char*)strbuf.c; ++ *buf_len = strbuf.len; ++ smart_str_0(&strbuf); ++ return 1; ++ } ++ return 0; ++} ++ ++int APC_UNSERIALIZER_NAME(php) (APC_UNSERIALIZER_ARGS) ++{ ++ const unsigned char *tmp = buf; ++ php_unserialize_data_t var_hash; ++ PHP_VAR_UNSERIALIZE_INIT(var_hash); ++ if(!php_var_unserialize(value, &tmp, buf + buf_len, &var_hash TSRMLS_CC)) { ++ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ++ zval_dtor(*value); ++ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %ld bytes", (long)(tmp - buf), (long)buf_len); ++ (*value)->type = IS_NULL; ++ return 0; ++ } ++ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ++ return 1; ++} ++/* }}} */ ++ +/* {{{ check_op_array_integrity */ +#if 0 +static void check_op_array_integrity(zend_op_array* src) @@ -3600,21 +3731,23 @@ +static zval* my_serialize_object(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + smart_str buf = {0}; -+ php_serialize_data_t var_hash; + apc_pool* pool = ctxt->pool; ++ apc_serialize_t serialize = APC_SERIALIZER_NAME(php); ++ void *config = NULL; + -+ PHP_VAR_SERIALIZE_INIT(var_hash); -+ php_var_serialize(&buf, (zval**)&src, &var_hash TSRMLS_CC); -+ PHP_VAR_SERIALIZE_DESTROY(var_hash); ++ if(APCG(serializer)) { /* TODO: move to ctxt */ ++ serialize = APCG(serializer)->serialize; ++ config = APCG(serializer)->config; ++ } + -+ if(buf.c) { ++ if(serialize((unsigned char**)&buf.c, &buf.len, src, config TSRMLS_CC)) { + dst->type = src->type & ~IS_CONSTANT_INDEX; + dst->value.str.len = buf.len; + CHECK(dst->value.str.val = apc_pmemcpy(buf.c, (buf.len + 1), pool TSRMLS_CC)); -+ dst->type = src->type; -+ smart_str_free(&buf); + } + ++ if(buf.c) smart_str_free(&buf); ++ + return dst; +} +/* }}} */ @@ -3622,17 +3755,21 @@ +/* {{{ my_unserialize_object */ +static zval* my_unserialize_object(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ php_unserialize_data_t var_hash; -+ const unsigned char *p = (unsigned char*)Z_STRVAL_P(src); ++ apc_unserialize_t unserialize = APC_UNSERIALIZER_NAME(php); ++ unsigned char *p = (unsigned char*)Z_STRVAL_P(src); ++ void *config = NULL; + -+ PHP_VAR_UNSERIALIZE_INIT(var_hash); -+ if(!php_var_unserialize(&dst, &p, p + Z_STRLEN_P(src), &var_hash TSRMLS_CC)) { -+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ++ if(APCG(serializer)) { /* TODO: move to ctxt */ ++ unserialize = APCG(serializer)->unserialize; ++ config = APCG(serializer)->config; ++ } ++ ++ if(unserialize(&dst, p, Z_STRLEN_P(src), config TSRMLS_CC)) { ++ return dst; ++ } else { + zval_dtor(dst); -+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", (long)((char*)p - Z_STRVAL_P(src)), Z_STRLEN_P(src)); + dst->type = IS_NULL; + } -+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + return dst; +} +/* }}} */ @@ -3640,18 +3777,20 @@ +static char *apc_string_pmemcpy(char *str, size_t len, apc_pool* pool TSRMLS_DC) +{ +#ifdef ZEND_ENGINE_2_4 ++#ifndef ZTS + if (pool->type != APC_UNPOOL) { -+ char * ret = apc_new_interned_string(str, len TSRMLS_CC); ++ char * ret = (char*)apc_new_interned_string((const char*)str, len TSRMLS_CC); + if (ret) { + return ret; + } + } +#endif ++#endif + return apc_pmemcpy(str, len, pool TSRMLS_CC); +} + +/* {{{ my_copy_zval */ -+static zval* my_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) ++static APC_HOTSPOT zval* my_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + zval **tmp; + apc_pool* pool = ctxt->pool; @@ -3704,14 +3843,19 @@ + + case IS_ARRAY: + case IS_CONSTANT_ARRAY: ++ if(APCG(serializer) == NULL || ++ ctxt->copy == APC_COPY_IN_OPCODE || ctxt->copy == APC_COPY_OUT_OPCODE) { + -+ CHECK(dst->value.ht = -+ my_copy_hashtable(NULL, -+ src->value.ht, -+ (ht_copy_fun_t) my_copy_zval_ptr, -+ 1, -+ ctxt)); -+ break; ++ CHECK(dst->value.ht = ++ my_copy_hashtable(NULL, ++ src->value.ht, ++ (ht_copy_fun_t) my_copy_zval_ptr, ++ 1, ++ ctxt)); ++ break; ++ } else { ++ /* fall through to object case */ ++ } + + case IS_OBJECT: + @@ -4165,7 +4309,7 @@ + } + + if (src->type == ZEND_INTERNAL_CLASS && ZEND_CE_BUILTIN_FUNCTIONS(src)) { -+ int i, n; ++ int n; + + for (n = 0; src->type == ZEND_INTERNAL_CLASS && ZEND_CE_BUILTIN_FUNCTIONS(src)[n].fname != NULL; n++) {} + @@ -4189,7 +4333,7 @@ +/* }}} */ + +/* {{{ my_copy_hashtable_ex */ -+static HashTable* my_copy_hashtable_ex(HashTable* dst, ++static APC_HOTSPOT HashTable* my_copy_hashtable_ex(HashTable* dst, + HashTable* src TSRMLS_DC, + ht_copy_fun_t copy_fn, + int holds_ptrs, @@ -4243,20 +4387,21 @@ + CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); + } else if (IS_INTERNED(curr->arKey)) { + CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); ++#ifndef ZTS + } else if (pool->type != APC_UNPOOL) { + char *arKey; + ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); + arKey = apc_new_interned_string(curr->arKey, curr->nKeyLength TSRMLS_CC); + if (!arKey) { -+ CHECK((newp = (Bucket*) apc_pmemcpy(curr, (sizeof(Bucket) + curr->nKeyLength), pool TSRMLS_CC))); -+ newp->arKey = ((char*)newp) + sizeof(Bucket); ++ CHECK((newp->arKey = (char*) apc_pmemcpy(curr->arKey, curr->nKeyLength, pool TSRMLS_CC))); + } else { -+ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); + newp->arKey = arKey; + } ++#endif + } else { -+ CHECK((newp = (Bucket*) apc_pmemcpy(curr, (sizeof(Bucket) + curr->nKeyLength), pool TSRMLS_CC))); -+ newp->arKey = ((char*)newp) + sizeof(Bucket); ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); ++ CHECK((newp->arKey = (char*) apc_pmemcpy(curr->arKey, curr->nKeyLength, pool TSRMLS_CC))); + } +#else + CHECK((newp = (Bucket*) apc_pmemcpy(curr, @@ -4304,6 +4449,8 @@ + + dst->pListTail = newp; + ++ zend_hash_internal_pointer_reset(dst); ++ + return dst; +} +/* }}} */ @@ -4373,6 +4520,9 @@ + case ZEND_JMP_SET: +#endif +#ifdef ZEND_ENGINE_2_4 ++ case ZEND_JMP_SET_VAR: ++#endif ++#ifdef ZEND_ENGINE_2_4 + zo->op2.jmp_addr = dst->opcodes + (zo->op2.jmp_addr - src->opcodes); +#else + zo->op2.u.jmp_addr = dst->opcodes + (zo->op2.u.jmp_addr - src->opcodes); @@ -4482,6 +4632,9 @@ +#ifdef ZEND_ENGINE_2_3 + case ZEND_JMP_SET: +#endif ++#ifdef ZEND_ENGINE_2_4 ++ case ZEND_JMP_SET_VAR: ++#endif + if(flags != NULL) { + flags->has_jumps = 1; + } @@ -4616,6 +4769,7 @@ + dzo->op1.literal = (zend_literal*) apc_pool_alloc(pool, sizeof(zend_literal)); + Z_STRLEN_P(dzo->op1.zv) = strlen(fullpath); + Z_STRVAL_P(dzo->op1.zv) = apc_pstrdup(fullpath, pool TSRMLS_CC); ++ Z_TYPE_P(dzo->op1.zv) = IS_STRING; + Z_SET_REFCOUNT_P(dzo->op1.zv, 2); + Z_SET_ISREF_P(dzo->op1.zv); + dzo->op1.literal->hash_value = zend_hash_func(Z_STRVAL_P(dzo->op1.zv), Z_STRLEN_P(dzo->op1.zv)+1); @@ -4939,6 +5093,9 @@ + case ZEND_JMP_SET: +#endif +#ifdef ZEND_ENGINE_2_4 ++ case ZEND_JMP_SET_VAR: ++#endif ++#ifdef ZEND_ENGINE_2_4 + dzo->op2.jmp_addr = dst->opcodes + + (zo->op2.jmp_addr - src->opcodes); +#else @@ -5051,6 +5208,7 @@ + /* Deep-copy the class properties, because they will be modified */ + +#ifdef ZEND_ENGINE_2_4 ++ dst->name = apc_string_pmemcpy((char*)src->name, src->name_length+1, ctxt->pool TSRMLS_CC); + dst->default_properties_count = src->default_properties_count; + if (src->default_properties_count) { + dst->default_properties_table = (zval**) apc_php_malloc((sizeof(zval*) * src->default_properties_count) TSRMLS_CC); @@ -5502,14 +5660,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_compile.h -@@ -0,0 +1,146 @@ +diff -Naur a/ext/apc/apc_compile.h b/ext/apc/apc_compile.h +--- a/ext/apc/apc_compile.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_compile.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,152 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5534,7 +5693,7 @@ + + */ + -+/* $Id: apc_compile.h 303388 2010-09-15 09:50:28Z dmitry $ */ ++/* $Id: apc_compile.h 307185 2011-01-06 21:13:11Z gopalv $ */ + +#ifndef APC_COMPILE_H +#define APC_COMPILE_H @@ -5548,6 +5707,7 @@ +#include "apc.h" +#include "apc_php.h" +#include "apc_main.h" ++#include "apc_serializer.h" + +/* {{{ struct definition: apc_function_t */ +typedef struct apc_function_t apc_function_t; @@ -5641,6 +5801,11 @@ +long apc_file_halt_offset(const char* filename TSRMLS_DC); +void apc_do_halt_compiler_register(const char *filename, long halt_offset TSRMLS_DC); + ++/* ++ * apc serialization functions ++ */ ++int APC_SERIALIZER_NAME(php) (APC_SERIALIZER_ARGS); ++int APC_UNSERIALIZER_NAME(php) (APC_UNSERIALIZER_ARGS); +#endif + +/* @@ -5651,14 +5816,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_debug.c +diff -Naur a/ext/apc/apc_debug.c b/ext/apc/apc_debug.c +--- a/ext/apc/apc_debug.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_debug.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,70 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5682,7 +5848,7 @@ + All other licensing and usage conditions are those of the PHP Group. +*/ + -+/* $Id: apc_debug.c 304107 2010-10-05 15:14:06Z kalle $ */ ++/* $Id: apc_debug.c 307048 2011-01-03 23:53:17Z kalle $ */ +#include "apc.h" +#include +#include "zend.h" @@ -5724,14 +5890,15 @@ + apc_warning("vld is not installed or something even worse." TSRMLS_CC); +#endif +} ---- /dev/null -+++ b/ext/apc/apc_debug.h +diff -Naur a/ext/apc/apc_debug.h b/ext/apc/apc_debug.h +--- a/ext/apc/apc_debug.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_debug.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,29 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5756,14 +5923,15 @@ +*/ + +void dump(zend_op_array * TSRMLS_DC); ---- /dev/null -+++ b/ext/apc/apc_fcntl.c +diff -Naur a/ext/apc/apc_fcntl.c b/ext/apc/apc_fcntl.c +--- a/ext/apc/apc_fcntl.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_fcntl.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,123 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5787,7 +5955,7 @@ + + */ + -+/* $Id: apc_fcntl.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_fcntl.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc.h" + @@ -5882,14 +6050,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_fcntl.h +diff -Naur a/ext/apc/apc_fcntl.h b/ext/apc/apc_fcntl.h +--- a/ext/apc/apc_fcntl.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_fcntl.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,50 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5913,7 +6082,7 @@ + + */ + -+/* $Id: apc_fcntl.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_fcntl.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_FCNTL_H +#define APC_FCNTL_H @@ -5935,14 +6104,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_fcntl_win32.c -@@ -0,0 +1,117 @@ +diff -Naur a/ext/apc/apc_fcntl_win32.c b/ext/apc/apc_fcntl_win32.c +--- a/ext/apc/apc_fcntl_win32.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_fcntl_win32.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,120 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5954,6 +6124,7 @@ + +----------------------------------------------------------------------+ + | Authors: George Schlossnagle | + | Edin Kadribasic | ++ | Pierre Joye | + +----------------------------------------------------------------------+ + + This software was contributed to PHP by Community Connect Inc. in 2002 @@ -5966,7 +6137,7 @@ + + */ + -+/* $Id: apc_fcntl_win32.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_fcntl_win32.c 309203 2011-03-14 06:47:16Z pajoye $ */ + +#include "apc.h" +#include "apc_fcntl.h" @@ -5979,18 +6150,23 @@ + +int apc_fcntl_create(const char* pathname TSRMLS_DC) +{ -+ char *lock_file = emalloc(MAXPATHLEN); ++ char lock_file[MAXPATHLEN]; + HANDLE fd; -+ DWORD tmplen; -+ static int i=0; ++ DWORD tmp_dirname_len; ++ char lock_filename_tpl[] = ".apc.XXXXXX"; ++ char *lock_filename; + -+ tmplen = GetTempPath(MAXPATHLEN, lock_file); -+ if (!tmplen) { -+ efree(lock_file); ++ tmp_dirname_len = GetTempPath(MAXPATHLEN, lock_file); ++ if (!tmp_dirname_len) { + return -1; + } + -+ snprintf(lock_file + tmplen, MAXPATHLEN - tmplen - 1, "apc.lock.%d", i++); ++ lock_filename = _mktemp(lock_filename_tpl); ++ if (lock_filename == NULL) { ++ return -1; ++ } ++ ++ snprintf(lock_file + tmp_dirname_len, MAXPATHLEN - tmp_dirname_len - 1, "%s", lock_filename); + + fd = CreateFile(lock_file, + GENERIC_READ | GENERIC_WRITE, @@ -6000,14 +6176,11 @@ + FILE_ATTRIBUTE_NORMAL, + NULL); + -+ + if (fd == INVALID_HANDLE_VALUE) { + apc_error("apc_fcntl_create: could not open %s" TSRMLS_CC, lock_file); -+ efree(lock_file); + return -1; + } + -+ efree(lock_file); + return (int)fd; +} + @@ -6055,14 +6228,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_globals.h -@@ -0,0 +1,148 @@ +diff -Naur a/ext/apc/apc_globals.h b/ext/apc/apc_globals.h +--- a/ext/apc/apc_globals.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_globals.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,152 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6089,7 +6263,7 @@ + + */ + -+/* $Id: apc_globals.h 301232 2010-07-13 12:23:35Z gopalv $ */ ++/* $Id: apc_globals.h 307215 2011-01-07 09:54:00Z gopalv $ */ + +#ifndef APC_GLOBALS_H +#define APC_GLOBALS_H @@ -6097,6 +6271,7 @@ +#include "apc_cache.h" +#include "apc_stack.h" +#include "apc_php.h" ++#include "apc_main.h" + +/* {{{ struct apc_rfc1867_data */ + @@ -6119,6 +6294,7 @@ +}; +/* }}} */ + ++ +ZEND_BEGIN_MODULE_GLOBALS(apc) + /* configuration parameters */ + zend_bool enabled; /* if true, apc is enabled (defaults to true) */ @@ -6180,6 +6356,8 @@ +#ifdef ZEND_ENGINE_2_4 + long shm_strings_buffer; +#endif ++ char *serializer_name; /* the serializer config option */ ++ apc_serializer_t *serializer;/* the actual serializer in use */ +ZEND_END_MODULE_GLOBALS(apc) + +/* (the following declaration is defined in php_apc.c) */ @@ -6206,14 +6384,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc.h -@@ -0,0 +1,124 @@ +diff -Naur a/ext/apc/apc.h b/ext/apc/apc.h +--- a/ext/apc/apc.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,136 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6240,7 +6419,7 @@ + + */ + -+/* $Id: apc.h 304310 2010-10-11 12:19:24Z gopalv $ */ ++/* $Id: apc.h 307264 2011-01-08 13:20:20Z gopalv $ */ + +#ifndef APC_H +#define APC_H @@ -6321,7 +6500,19 @@ +#define APC_POSITIVE_MATCH 2 + +#define apc_time() \ -+ (APCG(use_request_time) ? sapi_get_request_time(TSRMLS_C) : time(0)); ++ (APCG(use_request_time) ? (time_t) sapi_get_request_time(TSRMLS_C) : time(0)); ++ ++#if defined(__GNUC__) ++# define APC_UNUSED __attribute__((unused)) ++# define APC_USED __attribute__((used)) ++# define APC_ALLOC __attribute__((malloc)) ++# define APC_HOTSPOT __attribute__((hot)) ++#else ++# define APC_UNUSED ++# define APC_USED ++# define APC_ALLOC ++# define APC_HOTSPOT ++#endif + +#endif + @@ -6333,14 +6524,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_iterator.c -@@ -0,0 +1,710 @@ +diff -Naur a/ext/apc/apc_iterator.c b/ext/apc/apc_iterator.c +--- a/ext/apc/apc_iterator.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_iterator.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,741 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6355,7 +6547,7 @@ + + */ + -+/* $Id: apc_iterator.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_iterator.c 324326 2012-03-18 13:19:50Z pajoye $ */ + +#include "php_apc.h" +#include "apc_iterator.h" @@ -6456,7 +6648,7 @@ + } + if (APC_ITER_MD5 & iterator->format) { + if(slot->value->type == APC_CACHE_ENTRY_FILE) { -+ if(slot->key.md5) { ++ if(APCG(file_md5) && slot->key.md5) { + make_digest(md5str, slot->key.md5); + add_assoc_string(item->value, "md5", md5str, 1); + } @@ -6555,6 +6747,9 @@ + iterator->obj.ce = ce; + ALLOC_HASHTABLE(iterator->obj.properties); + zend_hash_init(iterator->obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0); ++#ifdef ZEND_ENGINE_2_4 ++ iterator->obj.properties_table = NULL; ++#endif + iterator->obj.guards = NULL; + iterator->initialized = 0; + retval.handle = zend_objects_store_put(iterator, apc_iterator_destroy, apc_iterator_free, NULL TSRMLS_CC); @@ -6571,11 +6766,11 @@ + char *key; + int key_len; + char *fname_key = NULL; -+ int fname_key_len; ++ int fname_key_len = 0; + int rval = 1; + + if ((*slot)->key.type == APC_CACHE_KEY_FILE) { -+ key = estrdup((*slot)->value->data.file.filename); ++ key = (*slot)->value->data.file.filename; + key_len = strlen(key); + fname_key_len = spprintf(&fname_key, 0, "%ld %ld", (*slot)->key.data.file.device, (*slot)->key.data.file.inode); + } else if ((*slot)->key.type == APC_CACHE_KEY_USER) { @@ -6584,6 +6779,8 @@ + } else if ((*slot)->key.type == APC_CACHE_KEY_FPFILE) { + key = (char*)(*slot)->key.data.fpfile.fullpath; + key_len = (*slot)->key.data.fpfile.fullpath_len; ++ } else { ++ return 0; + } + +#ifdef ITERATOR_PCRE @@ -6603,11 +6800,35 @@ +} +/* }}} */ + ++/* {{{ apc_iterator_check_expiry */ ++static int apc_iterator_check_expiry(apc_cache_t* cache, slot_t **slot, time_t t) ++{ ++ if((*slot)->value->type == APC_CACHE_ENTRY_USER) { ++ if((*slot)->value->data.user.ttl) { ++ if((time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t) { ++ return 0; ++ } ++ } else if(cache->ttl) { ++ if((*slot)->creation_time + cache->ttl < t) { ++ return 0; ++ } ++ } ++ } else if((*slot)->access_time < (t - cache->ttl)) { ++ return 0; ++ } ++ ++ return 1; ++} ++/* }}} */ ++ +/* {{{ apc_iterator_fetch_active */ +static int apc_iterator_fetch_active(apc_iterator_t *iterator TSRMLS_DC) { + int count=0; + slot_t **slot; + apc_iterator_item_t *item; ++ time_t t; ++ ++ t = apc_time(); + + while (apc_stack_size(iterator->stack) > 0) { + apc_iterator_item_dtor(apc_stack_pop(iterator->stack)); @@ -6617,11 +6838,13 @@ + while(count <= iterator->chunk_size && iterator->slot_idx < iterator->cache->num_slots) { + slot = &iterator->cache->slots[iterator->slot_idx]; + while(*slot) { -+ if (apc_iterator_search_match(iterator, slot)) { -+ count++; -+ item = apc_iterator_item_ctor(iterator, slot TSRMLS_CC); -+ if (item) { -+ apc_stack_push(iterator->stack, item TSRMLS_CC); ++ if (apc_iterator_check_expiry(iterator->cache, slot, t)) { ++ if (apc_iterator_search_match(iterator, slot)) { ++ count++; ++ item = apc_iterator_item_ctor(iterator, slot TSRMLS_CC); ++ if (item) { ++ apc_stack_push(iterator->stack, item TSRMLS_CC); ++ } + } + } + slot = &(*slot)->next; @@ -7046,14 +7269,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_iterator.h +diff -Naur a/ext/apc/apc_iterator.h b/ext/apc/apc_iterator.h +--- a/ext/apc/apc_iterator.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_iterator.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,117 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -7068,7 +7292,7 @@ + + */ + -+/* $Id: apc_iterator.h 300979 2010-07-04 10:15:05Z kalle $ */ ++/* $Id: apc_iterator.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_ITERATOR_H +#define APC_ITERATOR_H @@ -7166,14 +7390,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_lock.h -@@ -0,0 +1,101 @@ +diff -Naur a/ext/apc/apc_lock.h b/ext/apc/apc_lock.h +--- a/ext/apc/apc_lock.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_lock.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,160 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -7185,6 +7410,7 @@ + +----------------------------------------------------------------------+ + | Authors: George Schlossnagle | + | Rasmus Lerdorf | ++ | Pierre Joye | + +----------------------------------------------------------------------+ + + This software was contributed to PHP by Community Connect Inc. in 2002 @@ -7197,19 +7423,22 @@ + + */ + -+/* $Id: apc_lock.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_lock.h 311339 2011-05-22 17:18:49Z gopalv $ */ + +#ifndef APC_LOCK +#define APC_LOCK + ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ +#include "apc.h" +#include "apc_sem.h" +#include "apc_fcntl.h" +#include "apc_pthreadmutex.h" ++#include "apc_pthreadrwlock.h" +#include "apc_spin.h" -+#ifdef HAVE_CONFIG_H -+#include -+#endif ++#include "apc_windows_srwlock_kernel.h" + +/* {{{ generic locking macros */ +#define CREATE_LOCK(lock) apc_lck_create(NULL, 0, 1, lock) @@ -7217,67 +7446,123 @@ +#define LOCK(lock) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_lock(lock); } +#define RDLOCK(lock) { HANDLE_BLOCK_INTERRUPTIONS(); apc_lck_rdlock(lock); } +#define UNLOCK(lock) { apc_lck_unlock(lock); HANDLE_UNBLOCK_INTERRUPTIONS(); } ++#define RDUNLOCK(lock) { apc_lck_rdunlock(lock); HANDLE_UNBLOCK_INTERRUPTIONS(); } +/* }}} */ + -+#if defined(APC_SEM_LOCKS) -+#define APC_LOCK_TYPE "IPC Semaphore" -+#define RDLOCK_AVAILABLE 0 -+#define NONBLOCKING_LOCK_AVAILABLE 1 -+#define apc_lck_t int -+#define apc_lck_create(a,b,c,d) d=apc_sem_create((b),(c) TSRMLS_CC) -+#define apc_lck_destroy(a) apc_sem_destroy(a) -+#define apc_lck_lock(a) apc_sem_lock(a TSRMLS_CC) -+#define apc_lck_nb_lock(a) apc_sem_nonblocking_lock(a TSRMLS_CC) -+#define apc_lck_rdlock(a) apc_sem_lock(a TSRMLS_CC) -+#define apc_lck_unlock(a) apc_sem_unlock(a TSRMLS_CC) -+#elif defined(APC_PTHREADMUTEX_LOCKS) -+#define APC_LOCK_TYPE "pthread mutex Locks" -+#define RDLOCK_AVAILABLE 0 -+#define NONBLOCKING_LOCK_AVAILABLE 1 -+#define apc_lck_t pthread_mutex_t -+#define apc_lck_create(a,b,c,d) apc_pthreadmutex_create((pthread_mutex_t*)&d TSRMLS_CC) -+#define apc_lck_destroy(a) apc_pthreadmutex_destroy(&a) -+#define apc_lck_lock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) -+#define apc_lck_nb_lock(a) apc_pthreadmutex_nonblocking_lock(&a TSRMLS_CC) -+#define apc_lck_rdlock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) -+#define apc_lck_unlock(a) apc_pthreadmutex_unlock(&a TSRMLS_CC) -+#elif defined(APC_SPIN_LOCKS) -+#define APC_LOCK_TYPE "spin Locks" -+#define RDLOCK_AVAILABLE 0 -+#define NONBLOCKING_LOCK_AVAILABLE APC_SLOCK_NONBLOCKING_LOCK_AVAILABLE -+#define apc_lck_t slock_t -+#define apc_lck_create(a,b,c,d) apc_slock_create((slock_t*)&(d)) -+#define apc_lck_destroy(a) apc_slock_destroy(&a) -+#define apc_lck_lock(a) apc_slock_lock(&a TSRMLS_CC) -+#define apc_lck_nb_lock(a) apc_slock_nonblocking_lock(&a) -+#define apc_lck_rdlock(a) apc_slock_lock(&a TSRMLS_CC) -+#define apc_lck_unlock(a) apc_slock_unlock(&a) -+#else -+#define APC_LOCK_TYPE "File Locks" -+#define RDLOCK_AVAILABLE 1 -+#ifdef PHP_WIN32 -+#define NONBLOCKING_LOCK_AVAILABLE 0 -+#else -+#define NONBLOCKING_LOCK_AVAILABLE 1 ++/* atomic operations : rdlocks are impossible without these */ ++#if HAVE_ATOMIC_OPERATIONS ++# ifdef PHP_WIN32 ++# define ATOMIC_INC(a) InterlockedIncrement(&a) ++# define ATOMIC_DEC(a) InterlockedDecrement(&a) ++# else ++# define ATOMIC_INC(a) __sync_add_and_fetch(&a, 1) ++# define ATOMIC_DEC(a) __sync_sub_and_fetch(&a, 1) ++# endif +#endif -+#define apc_lck_t int -+#define apc_lck_create(a,b,c,d) d=apc_fcntl_create((a) TSRMLS_CC) -+#define apc_lck_destroy(a) apc_fcntl_destroy(a) -+#define apc_lck_lock(a) apc_fcntl_lock(a TSRMLS_CC) -+#define apc_lck_nb_lock(a) apc_fcntl_nonblocking_lock(a TSRMLS_CC) -+#define apc_lck_rdlock(a) apc_fcntl_rdlock(a TSRMLS_CC) -+#define apc_lck_unlock(a) apc_fcntl_unlock(a TSRMLS_CC) ++ ++#if defined(APC_SEM_LOCKS) ++# define APC_LOCK_TYPE "IPC Semaphore" ++# define RDLOCK_AVAILABLE 0 ++# define NONBLOCKING_LOCK_AVAILABLE 1 ++# define apc_lck_t int ++# define apc_lck_create(a,b,c,d) d=apc_sem_create((b),(c) TSRMLS_CC) ++# define apc_lck_destroy(a) apc_sem_destroy(a) ++# define apc_lck_lock(a) apc_sem_lock(a TSRMLS_CC) ++# define apc_lck_nb_lock(a) apc_sem_nonblocking_lock(a TSRMLS_CC) ++# define apc_lck_rdlock(a) apc_sem_lock(a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_sem_unlock(a TSRMLS_CC) ++# define apc_lck_rdunlock(a) apc_sem_unlock(a TSRMLS_CC) ++#elif defined(APC_PTHREADMUTEX_LOCKS) ++# define APC_LOCK_TYPE "pthread mutex Locks" ++# define RDLOCK_AVAILABLE 0 ++# define NONBLOCKING_LOCK_AVAILABLE 1 ++# define apc_lck_t pthread_mutex_t ++# define apc_lck_create(a,b,c,d) apc_pthreadmutex_create((pthread_mutex_t*)&d TSRMLS_CC) ++# define apc_lck_destroy(a) apc_pthreadmutex_destroy(&a) ++# define apc_lck_lock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) ++# define apc_lck_nb_lock(a) apc_pthreadmutex_nonblocking_lock(&a TSRMLS_CC) ++# define apc_lck_rdlock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_pthreadmutex_unlock(&a TSRMLS_CC) ++# define apc_lck_rdunlock(a) apc_pthreadmutex_unlock(&a TSRMLS_CC) ++#elif defined(APC_PTHREADRW_LOCKS) ++# define APC_LOCK_TYPE "pthread read/write Locks" ++# define RDLOCK_AVAILABLE 1 ++# define NONBLOCKING_LOCK_AVAILABLE 1 ++# define apc_lck_t pthread_rwlock_t ++# define apc_lck_create(a,b,c,d) apc_pthreadrwlock_create((pthread_rwlock_t*)&d TSRMLS_CC) ++# define apc_lck_destroy(a) apc_pthreadrwlock_destroy(&a) ++# define apc_lck_lock(a) apc_pthreadrwlock_lock(&a TSRMLS_CC) ++# define apc_lck_nb_lock(a) apc_pthreadrwlock_nonblocking_lock(&a TSRMLS_CC) ++# define apc_lck_rdlock(a) apc_pthreadrwlock_rdlock(&a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_pthreadrwlock_unlock(&a TSRMLS_CC) ++# define apc_lck_rdunlock(a) apc_pthreadrwlock_unlock(&a TSRMLS_CC) ++#elif defined(APC_SPIN_LOCKS) ++# define APC_LOCK_TYPE "spin Locks" ++# define RDLOCK_AVAILABLE 0 ++# define NONBLOCKING_LOCK_AVAILABLE APC_SLOCK_NONBLOCKING_LOCK_AVAILABLE ++# define apc_lck_t slock_t ++# define apc_lck_create(a,b,c,d) apc_slock_create((slock_t*)&(d)) ++# define apc_lck_destroy(a) apc_slock_destroy(&a) ++# define apc_lck_lock(a) apc_slock_lock(&a TSRMLS_CC) ++# define apc_lck_nb_lock(a) apc_slock_nonblocking_lock(&a) ++# define apc_lck_rdlock(a) apc_slock_lock(&a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_slock_unlock(&a) ++# define apc_lck_rdunlock(a) apc_slock_unlock(&a) ++#elif defined(APC_SRWLOCK_NATIVE) && defined(PHP_WIN32) ++# define APC_LOCK_TYPE "Windows Slim RWLOCK (native)" ++# define RDLOCK_AVAILABLE 1 ++# define NONBLOCKING_LOCK_AVAILABLE 0 ++# define apc_lck_t SRWLOCK ++# define apc_lck_create(a,b,c,d) InitializeSRWLock((SRWLOCK*)&(d)) ++# define apc_lck_destroy(a) ++# define apc_lck_lock(a) AcquireSRWLockExclusive(&a) ++# define apc_lck_rdlock(a) AcquireSRWLockShared(&a) ++# define apc_lck_unlock(a) ReleaseSRWLockExclusive(&a) ++# define apc_lck_rdunlock(a) ReleaseSRWLockShared(&a) ++# if NONBLOCKING_LOCK_AVAILABLE==1 /* Only in win7/2008 */ ++# define apc_lck_nb_lock(a) (TryAcquireSRWLockExclusive(&a TSRMLS_CC) == 0 ? 1 : 0); ++# endif ++#elif defined(APC_SRWLOCK_KERNEL) && defined(PHP_WIN32) ++# define APC_LOCK_TYPE "Windows Slim RWLOCK (kernel)" ++# define RDLOCK_AVAILABLE 1 ++# define NONBLOCKING_LOCK_AVAILABLE 0 ++# define apc_lck_t apc_windows_cs_rwlock_t ++# define apc_lck_create(a,b,c,d) apc_windows_cs_create((apc_windows_cs_rwlock_t*)&(d) TSRMLS_CC) ++# define apc_lck_destroy(a) apc_windows_cs_destroy(&a); ++# define apc_lck_lock(a) apc_windows_cs_lock(&a TSRMLS_CC) ++# define apc_lck_rdlock(a) apc_windows_cs_rdlock(&a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_windows_cs_unlock_wr(&a TSRMLS_CC) ++# define apc_lck_rdunlock(a) apc_windows_cs_unlock_rd(&a TSRMLS_CC) ++#else ++# define APC_LOCK_TYPE "File Locks" ++# ifdef HAVE_ATOMIC_OPERATIONS ++# define RDLOCK_AVAILABLE 1 ++# endif ++# ifdef PHP_WIN32 ++# define NONBLOCKING_LOCK_AVAILABLE 0 ++# else ++# define NONBLOCKING_LOCK_AVAILABLE 1 ++# endif ++# define apc_lck_t int ++# define apc_lck_create(a,b,c,d) d=apc_fcntl_create((a) TSRMLS_CC) ++# define apc_lck_destroy(a) apc_fcntl_destroy(a) ++# define apc_lck_lock(a) apc_fcntl_lock(a TSRMLS_CC) ++# define apc_lck_nb_lock(a) apc_fcntl_nonblocking_lock(a TSRMLS_CC) ++# define apc_lck_rdlock(a) apc_fcntl_rdlock(a TSRMLS_CC) ++# define apc_lck_unlock(a) apc_fcntl_unlock(a TSRMLS_CC) ++# define apc_lck_rdunlock(a) apc_fcntl_unlock(a TSRMLS_CC) +#endif + +#endif ---- /dev/null -+++ b/ext/apc/apc_main.c -@@ -0,0 +1,969 @@ +diff -Naur a/ext/apc/apc_main.c b/ext/apc/apc_main.c +--- a/ext/apc/apc_main.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_main.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,1030 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -7303,7 +7588,7 @@ + + */ + -+/* $Id: apc_main.c 304994 2010-10-30 20:33:46Z gopalv $ */ ++/* $Id: apc_main.c 324326 2012-03-18 13:19:50Z pajoye $ */ + +#include "apc_php.h" +#include "apc_main.h" @@ -7322,11 +7607,14 @@ +#include "ext/standard/php_var.h" +#include "ext/standard/md5.h" + ++#define APC_MAX_SERIALIZERS 16 ++ +/* {{{ module variables */ + +/* pointer to the original Zend engine compile_file function */ +typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC); +static zend_compile_t *old_compile_file; ++static apc_serializer_t apc_serializers[APC_MAX_SERIALIZERS] = {{0,}}; + +/* }}} */ + @@ -7663,7 +7951,7 @@ +/* }}} */ + +/* {{{ apc_compile_cache_entry */ -+zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array, apc_cache_entry_t** cache_entry TSRMLS_DC) { ++zend_bool apc_compile_cache_entry(apc_cache_key_t *key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array, apc_cache_entry_t** cache_entry TSRMLS_DC) { + int num_functions, num_classes; + apc_function_t* alloc_functions; + zend_op_array* alloc_op_array; @@ -7709,7 +7997,7 @@ + while((n = php_stream_read(stream, (char*)buf, sizeof(buf))) > 0) { + PHP_MD5Update(&context, buf, n); + } -+ PHP_MD5Final(key.md5, &context); ++ PHP_MD5Final(key->md5, &context); + php_stream_close(stream); + if(n<0) { + apc_warning("Error while reading '%s' for md5 generation." TSRMLS_CC, filename); @@ -7731,6 +8019,7 @@ + } + + path = h->opened_path; ++ if(!path && key->type == APC_CACHE_KEY_FPFILE) path = (char*)key->data.fpfile.fullpath; + if(!path) path=h->filename; + + apc_debug("2. h->opened_path=[%s] h->filename=[%s]\n" TSRMLS_CC, h->opened_path?h->opened_path:"null",h->filename); @@ -7761,7 +8050,7 @@ + time_t t; + apc_context_t ctxt = {0,}; + int bailout=0; -+ const char* filename = NULL; ++ const char* filename = NULL; + + if (!APCG(enabled) || apc_cache_busy(apc_cache)) { + return old_compile_file(h, type TSRMLS_CC); @@ -7878,7 +8167,7 @@ +#endif + + zend_try { -+ if (apc_compile_cache_entry(key, h, type, t, &op_array, &cache_entry TSRMLS_CC) == SUCCESS) { ++ if (apc_compile_cache_entry(&key, h, type, t, &op_array, &cache_entry TSRMLS_CC) == SUCCESS) { + ctxt.pool = cache_entry->pool; + ctxt.copy = APC_COPY_IN_OPCODE; + if (apc_cache_insert(apc_cache, key, cache_entry, &ctxt, t TSRMLS_CC) != 1) { @@ -8023,6 +8312,50 @@ +} +/* }}} */ + ++/* {{{ apc_serializer hooks */ ++static int _apc_register_serializer(const char* name, apc_serialize_t serialize, ++ apc_unserialize_t unserialize, ++ void *config TSRMLS_DC) ++{ ++ int i; ++ apc_serializer_t *serializer; ++ ++ for(i = 0; i < APC_MAX_SERIALIZERS; i++) { ++ serializer = &apc_serializers[i]; ++ if(!serializer->name) { ++ /* empty entry */ ++ serializer->name = name; /* assumed to be const */ ++ serializer->serialize = serialize; ++ serializer->unserialize = unserialize; ++ serializer->config = config; ++ apc_serializers[i+1].name = NULL; ++ return 1; ++ } ++ } ++ ++ return 0; ++} ++ ++apc_serializer_t* apc_find_serializer(const char* name TSRMLS_DC) ++{ ++ int i; ++ apc_serializer_t *serializer; ++ ++ for(i = 0; i < APC_MAX_SERIALIZERS; i++) { ++ serializer = &apc_serializers[i]; ++ if(serializer->name && (strcmp(serializer->name, name) == 0)) { ++ return serializer; ++ } ++ } ++ return NULL; ++} ++ ++apc_serializer_t* apc_get_serializers(TSRMLS_D) ++{ ++ return &(apc_serializers[0]); ++} ++/* }}} */ ++ +/* {{{ module init and shutdown */ + +int apc_module_init(int module_number TSRMLS_DC) @@ -8041,6 +8374,12 @@ + zend_compile_file = my_compile_file; + REGISTER_LONG_CONSTANT("\000apc_magic", (long)&set_compile_hook, CONST_PERSISTENT | CONST_CS); + REGISTER_LONG_CONSTANT("\000apc_compile_file", (long)&my_compile_file, CONST_PERSISTENT | CONST_CS); ++ REGISTER_LONG_CONSTANT(APC_SERIALIZER_CONSTANT, (long)&_apc_register_serializer, CONST_PERSISTENT | CONST_CS); ++ ++ /* test out the constant function pointer */ ++ apc_register_serializer("php", APC_SERIALIZER_NAME(php), APC_UNSERIALIZER_NAME(php), NULL TSRMLS_CC); ++ ++ assert(apc_serializers[0].name != NULL); + + apc_pool_init(); + @@ -8063,8 +8402,10 @@ +#endif + +#ifdef ZEND_ENGINE_2_4 ++#ifndef ZTS + apc_interned_strings_init(TSRMLS_C); +#endif ++#endif + + APCG(initialized) = 1; + return 0; @@ -8108,14 +8449,16 @@ + apc_cache_release(apc_cache, cache_entry TSRMLS_CC); + } + ++#ifdef ZEND_ENGINE_2_4 ++#ifndef ZTS ++ apc_interned_strings_shutdown(TSRMLS_C); ++#endif ++#endif ++ + apc_cache_destroy(apc_cache TSRMLS_CC); + apc_cache_destroy(apc_user_cache TSRMLS_CC); + apc_sma_cleanup(TSRMLS_C); + -+#ifdef ZEND_ENGINE_2_4 -+ apc_interned_strings_shutdown(TSRMLS_C); -+#endif -+ + APCG(initialized) = 0; + return 0; +} @@ -8189,6 +8532,11 @@ + APCG(compiled_filters) = apc_regex_compile_array(APCG(filters) TSRMLS_CC); + } + ++ if (!APCG(serializer) && APCG(serializer_name)) { ++ /* Avoid race conditions between MINIT of apc and serializer exts like igbinary */ ++ APCG(serializer) = apc_find_serializer(APCG(serializer_name) TSRMLS_CC); ++ } ++ +#if APC_HAVE_LOOKUP_HOOKS + if(APCG(lazy_functions)) { + APCG(lazy_function_table) = emalloc(sizeof(HashTable)); @@ -8210,7 +8558,6 @@ + +int apc_request_shutdown(TSRMLS_D) +{ -+ +#if APC_HAVE_LOOKUP_HOOKS + if(APCG(lazy_class_table)) { + zend_hash_destroy(APCG(lazy_class_table)); @@ -8227,7 +8574,6 @@ +#ifdef APC_FILEHITS + zval_ptr_dtor(&APCG(filehits)); +#endif -+ + return 0; +} + @@ -8242,14 +8588,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_main.h -@@ -0,0 +1,74 @@ +diff -Naur a/ext/apc/apc_main.h b/ext/apc/apc_main.h +--- a/ext/apc/apc_main.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_main.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,88 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -8276,12 +8623,13 @@ + + */ + -+/* $Id: apc_main.h 300979 2010-07-04 10:15:05Z kalle $ */ ++/* $Id: apc_main.h 308594 2011-02-23 12:35:33Z gopalv $ */ + +#ifndef APC_MAIN_H +#define APC_MAIN_H + +#include "apc_pool.h" ++#include "apc_serializer.h" + +/* + * This module provides the primary interface between PHP and APC. @@ -8309,6 +8657,19 @@ + unsigned int force_update:1; +} apc_context_t; + ++/* {{{ struct apc_serializer_t */ ++typedef struct apc_serializer_t apc_serializer_t; ++struct apc_serializer_t { ++ const char *name; ++ apc_serialize_t serialize; ++ apc_unserialize_t unserialize; ++ void *config; ++}; ++/* }}} */ ++ ++apc_serializer_t* apc_get_serializers(TSRMLS_D); ++apc_serializer_t* apc_find_serializer(const char* name TSRMLS_DC); ++ +#endif + +/* @@ -8319,14 +8680,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_mmap.c -@@ -0,0 +1,175 @@ +diff -Naur a/ext/apc/apc_mmap.c b/ext/apc/apc_mmap.c +--- a/ext/apc/apc_mmap.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_mmap.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,177 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -8349,7 +8711,7 @@ + + */ + -+/* $Id: apc_mmap.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_mmap.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc.h" +#include "apc_mmap.h" @@ -8447,6 +8809,7 @@ + } + + segment.shmaddr = (void *)mmap(NULL, size, PROT_READ | PROT_WRITE, flags, fd, 0); ++ segment.size = size; + +#ifdef APC_MEMPROTECT + if(remap) { @@ -8467,6 +8830,7 @@ +error: + + segment.shmaddr = (void*)-1; ++ segment.size = 0; +#ifdef APC_MEMPROTECT + segment.roaddr = NULL; +#endif @@ -8497,14 +8861,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_mmap.h +diff -Naur a/ext/apc/apc_mmap.h b/ext/apc/apc_mmap.h +--- a/ext/apc/apc_mmap.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_mmap.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -8527,7 +8892,7 @@ + + */ + -+/* $Id: apc_mmap.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_mmap.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_MMAP_H +#define APC_MMAP_H @@ -8554,15 +8919,16 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc.php +diff -Naur a/ext/apc/apc.php b/ext/apc/apc.php +--- a/ext/apc/apc.php 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc.php 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,1362 @@ + '/^[AHSMCDTZ]$/', // first sort key + 'SORT2' => '/^[DA]$/', // second sort key + 'AGGR' => '/^\d+$/', // aggregation by dir level -+ 'SEARCH' => '~^[a-zA-Z0-1/_.-]*$~' // aggregation by dir level ++ 'SEARCH' => '~^[a-zA-Z0-9/_.-]*$~' // aggregation by dir level +); + +// default cache mode @@ -9919,14 +10285,15 @@ + + + ---- /dev/null -+++ b/ext/apc/apc_php.h -@@ -0,0 +1,77 @@ +diff -Naur a/ext/apc/apc_php.h b/ext/apc/apc_php.h +--- a/ext/apc/apc_php.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_php.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,81 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -9953,7 +10320,7 @@ + + */ + -+/* $Id: apc_php.h 300979 2010-07-04 10:15:05Z kalle $ */ ++/* $Id: apc_php.h 313808 2011-07-28 06:17:10Z gopalv $ */ + +#ifndef APC_PHP_H +#define APC_PHP_H @@ -9987,6 +10354,10 @@ +#include "zend_vm.h" +#endif + ++#ifndef IS_CONSTANT_TYPE_MASK ++#define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) ++#endif ++ +#include "rfc1867.h" + +#endif @@ -9999,14 +10370,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_php_pcre.h +diff -Naur a/ext/apc/apc_php_pcre.h b/ext/apc/apc_php_pcre.h +--- a/ext/apc/apc_php_pcre.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_php_pcre.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,98 @@ +/* + +----------------------------------------------------------------------+ + | APC/PHP Version 5 | + +----------------------------------------------------------------------+ -+ | Copyright (c) 1997-2010 The PHP Group | ++ | Copyright (c) 1997-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10020,7 +10392,7 @@ + +----------------------------------------------------------------------+ + */ + -+/* $Id: apc_php_pcre.h 300979 2010-07-04 10:15:05Z kalle $ */ ++/* $Id: apc_php_pcre.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef PHP_PCRE_H +#define PHP_PCRE_H @@ -10100,14 +10472,15 @@ +#define phpext_pcre_ptr pcre_module_ptr + +#endif /* PHP_PCRE_H */ ---- /dev/null -+++ b/ext/apc/apc_pool.c -@@ -0,0 +1,488 @@ +diff -Naur a/ext/apc/apc_pool.c b/ext/apc/apc_pool.c +--- a/ext/apc/apc_pool.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pool.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,507 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10130,7 +10503,7 @@ + + */ + -+/* $Id: apc_pool.c 301964 2010-08-07 03:34:18Z rasmus $ */ ++/* $Id: apc_pool.c 307555 2011-01-18 07:17:21Z gopalv $ */ + + +#include "apc_pool.h" @@ -10273,6 +10646,8 @@ + size_t dsize; + void *owner; + ++ unsigned long count; ++ + pool_block *head; + pool_block first; +}; @@ -10327,6 +10702,8 @@ + + rpool->parent.size += realsize; + ++ rpool->count++; ++ + return entry; +} +/* }}} */ @@ -10342,6 +10719,7 @@ + size_t redsize = 0; + size_t *sizeinfo= NULL; + pool_block *entry = NULL; ++ unsigned long i; + + if(APC_POOL_HAS_REDZONES(pool)) { + redsize = REDZONE_SIZE(size); /* redsize might be re-using word size padding */ @@ -10354,13 +10732,21 @@ + realsize += ALIGNWORD(sizeof(size_t)); + } + -+ -+ for(entry = rpool->head; entry != NULL; entry = entry->next) { ++ /* minimize look-back, a value of 8 seems to give similar fill-ratios (+2%) ++ * as looping through the entire list. And much faster in allocations. */ ++ for(entry = rpool->head, i = 0; entry != NULL && (i < 8); entry = entry->next, i++) { + if(entry->avail >= realsize) { + goto found; + } + } + ++ /* upgrade the pool type to reduce overhead */ ++ if(rpool->count > 4 && rpool->dsize < 4096) { ++ rpool->dsize = 4096; ++ } else if(rpool->count > 8 && rpool->dsize < 8192) { ++ rpool->dsize = 8192; ++ } ++ + poolsize = ALIGNSIZE(realsize, rpool->dsize); + + entry = create_pool_block(rpool, poolsize TSRMLS_CC); @@ -10408,8 +10794,12 @@ + * Checking integrity at runtime, does an + * overwrite check only when the sizeinfo + * is set. ++ * ++ * Marked as used in gcc, so that this function ++ * is accessible from gdb, eventhough it is never ++ * used in code in non-debug builds. + */ -+static int apc_realpool_check_integrity(apc_realpool *rpool) ++static APC_USED int apc_realpool_check_integrity(apc_realpool *rpool) +{ + apc_pool *pool = &(rpool->parent); + pool_block *entry; @@ -10428,6 +10818,7 @@ + + if(!APC_POOL_HAS_REDZONES(pool) || + !APC_POOL_HAS_SIZEINFO(pool)) { ++ (void)pool; /* remove unused warning */ + return 1; + } + @@ -10542,6 +10933,7 @@ + + rpool->dsize = dsize; + rpool->head = NULL; ++ rpool->count = 0; + + INIT_POOL_BLOCK(rpool, &(rpool->first), dsize); + @@ -10564,14 +10956,14 @@ +/* }}} */ + +/* {{{ apc_pstrdup */ -+void* apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC) ++void* APC_ALLOC apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC) +{ + return s != NULL ? apc_pmemcpy(s, (strlen(s) + 1), pool TSRMLS_CC) : NULL; +} +/* }}} */ + +/* {{{ apc_pmemcpy */ -+void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool TSRMLS_DC) ++void* APC_ALLOC apc_pmemcpy(const void* p, size_t n, apc_pool* pool TSRMLS_DC) +{ + void* q; + @@ -10591,14 +10983,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_pool.h +diff -Naur a/ext/apc/apc_pool.h b/ext/apc/apc_pool.h +--- a/ext/apc/apc_pool.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pool.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,114 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10621,7 +11014,7 @@ + + */ + -+/* $Id: apc_pool.h 301682 2010-07-29 11:09:00Z gopalv $ */ ++/* $Id: apc_pool.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_POOL_H +#define APC_POOL_H @@ -10708,14 +11101,15 @@ +extern void* apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC); + +#endif ---- /dev/null -+++ b/ext/apc/apc_pthreadmutex.c +diff -Naur a/ext/apc/apc_pthreadmutex.c b/ext/apc/apc_pthreadmutex.c +--- a/ext/apc/apc_pthreadmutex.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pthreadmutex.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,111 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10730,7 +11124,7 @@ + + */ + -+/* $Id: apc_pthreadmutex.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_pthreadmutex.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc_pthreadmutex.h" + @@ -10822,14 +11216,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_pthreadmutex.h +diff -Naur a/ext/apc/apc_pthreadmutex.h b/ext/apc/apc_pthreadmutex.h +--- a/ext/apc/apc_pthreadmutex.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pthreadmutex.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10844,7 +11239,7 @@ + + */ + -+/* $Id: apc_pthreadmutex.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_pthreadmutex.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_PTHREADMUTEX_H +#define APC_PTHREADMUTEX_H @@ -10873,14 +11268,192 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_rfc1867.c -@@ -0,0 +1,232 @@ +diff -Naur a/ext/apc/apc_pthreadrwlock.c b/ext/apc/apc_pthreadrwlock.c +--- a/ext/apc/apc_pthreadrwlock.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pthreadrwlock.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,120 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.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. | ++ +----------------------------------------------------------------------+ ++ | Authors: Gopal V | ++ +----------------------------------------------------------------------+ ++ ++ */ ++ ++/* $Id: $ */ ++ ++#include "apc_pthreadrwlock.h" ++ ++#ifdef APC_PTHREADRW_LOCKS ++ ++pthread_rwlock_t *apc_pthreadrwlock_create(pthread_rwlock_t *lock TSRMLS_DC) ++{ ++ int result; ++ pthread_rwlockattr_t attr; ++ ++ result = pthread_rwlockattr_init(&attr); ++ if(result == ENOMEM) { ++ apc_error("pthread rwlock error: Insufficient memory exists to create the rwlock attribute object." TSRMLS_CC); ++ } else if(result == EINVAL) { ++ apc_error("pthread rwlock error: attr does not point to writeable memory." TSRMLS_CC); ++ } else if(result == EFAULT) { ++ apc_error("pthread rwlock error: attr is an invalid pointer." TSRMLS_CC); ++ } ++ ++#ifdef __USE_UNIX98 ++ pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); ++#endif ++ ++ result = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); ++ if(result == EINVAL) { ++ apc_error("pthread rwlock error: attr is not an initialized rwlock attribute object, or pshared is not a valid process-shared state setting." TSRMLS_CC); ++ } else if(result == EFAULT) { ++ apc_error("pthread rwlock error: attr is an invalid pointer." TSRMLS_CC); ++ } else if(result == ENOTSUP) { ++ apc_error("pthread rwlock error: pshared was set to PTHREAD_PROCESS_SHARED." TSRMLS_CC); ++ } ++ ++ if(pthread_rwlock_init(lock, &attr)) { ++ apc_error("unable to initialize pthread rwlock" TSRMLS_CC); ++ } ++ ++ pthread_rwlockattr_destroy(&attr); ++ ++ return lock; ++} ++ ++void apc_pthreadrwlock_destroy(pthread_rwlock_t *lock) ++{ ++ return; /* we don't actually destroy the rwlock, as it would destroy it for all processes */ ++} ++ ++void apc_pthreadrwlock_lock(pthread_rwlock_t *lock TSRMLS_DC) ++{ ++ int result; ++ result = pthread_rwlock_wrlock(lock); ++ if(result == EINVAL) { ++ apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); ++ } else if(result == EDEADLK) { ++ apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); ++ } ++} ++ ++void apc_pthreadrwlock_rdlock(pthread_rwlock_t *lock TSRMLS_DC) ++{ ++ int result; ++ result = pthread_rwlock_rdlock(lock); ++ if(result == EINVAL) { ++ apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); ++ } else if(result == EDEADLK) { ++ apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); ++ } ++} ++ ++void apc_pthreadrwlock_unlock(pthread_rwlock_t *lock TSRMLS_DC) ++{ ++ if(pthread_rwlock_unlock(lock)) { ++ apc_error("unable to unlock pthread lock" TSRMLS_CC); ++ } ++} ++ ++zend_bool apc_pthreadrwlock_nonblocking_lock(pthread_rwlock_t *lock TSRMLS_DC) ++{ ++ int rval; ++ rval = pthread_rwlock_trywrlock(lock); ++ if(rval == EBUSY) { /* Lock is already held */ ++ return 0; ++ } else if(rval == 0) { /* Obtained lock */ ++ return 1; ++ } else { /* Other error */ ++ apc_error("unable to obtain pthread trylock" TSRMLS_CC); ++ return 0; ++ } ++} ++ ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff -Naur a/ext/apc/apc_pthreadrwlock.h b/ext/apc/apc_pthreadrwlock.h +--- a/ext/apc/apc_pthreadrwlock.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_pthreadrwlock.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,49 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.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. | ++ +----------------------------------------------------------------------+ ++ | Authors: Gopal V | ++ +----------------------------------------------------------------------+ ++ ++ */ ++ ++/* $Id: apc_pthreadrwlock.h 302175 2010-08-13 06:20:28Z kalle $ */ ++ ++#ifndef APC_PTHREADRWLOCK_H ++#define APC_PTHREADRWLOCK_H ++ ++#include "apc.h" ++ ++#ifdef APC_PTHREADRW_LOCKS ++ ++#include ++ ++pthread_rwlock_t *apc_pthreadrwlock_create(pthread_rwlock_t *lock TSRMLS_DC); ++void apc_pthreadrwlock_destroy(pthread_rwlock_t *lock); ++void apc_pthreadrwlock_lock(pthread_rwlock_t *lock TSRMLS_DC); ++void apc_pthreadrwlock_rdlock(pthread_rwlock_t *lock TSRMLS_DC); ++void apc_pthreadrwlock_unlock(pthread_rwlock_t *lock TSRMLS_DC); ++zend_bool apc_pthreadrwlock_nonblocking_lock(pthread_rwlock_t *lock TSRMLS_DC); ++ ++#endif ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff -Naur a/ext/apc/apc_rfc1867.c b/ext/apc/apc_rfc1867.c +--- a/ext/apc/apc_rfc1867.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_rfc1867.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,236 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10903,7 +11476,7 @@ + + */ + -+/* $Id: apc_rfc1867.c 305798 2010-11-28 13:43:20Z gopalv $*/ ++/* $Id: apc_rfc1867.c 309694 2011-03-25 18:47:38Z rasmus $*/ + +#include "apc.h" +#include "apc_globals.h" @@ -11057,7 +11630,11 @@ + multipart_event_file_end *data = (multipart_event_file_end *) event_data; + RFC1867_DATA(bytes_processed) = data->post_bytes_processed; + RFC1867_DATA(cancel_upload) = data->cancel_upload; -+ RFC1867_DATA(temp_filename) = data->temp_filename; ++ if(data->temp_filename) { ++ RFC1867_DATA(temp_filename) = data->temp_filename; ++ } else { ++ RFC1867_DATA(temp_filename) = ""; ++ } + ALLOC_INIT_ZVAL(track); + array_init(track); + add_assoc_long(track, "total", RFC1867_DATA(content_length)); @@ -11108,14 +11685,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_sem.c +diff -Naur a/ext/apc/apc_sem.c b/ext/apc/apc_sem.c +--- a/ext/apc/apc_sem.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_sem.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,192 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11138,7 +11716,7 @@ + + */ + -+/* $Id: apc_sem.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_sem.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc.h" + @@ -11303,14 +11881,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_sem.h +diff -Naur a/ext/apc/apc_sem.h b/ext/apc/apc_sem.h +--- a/ext/apc/apc_sem.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_sem.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,52 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11333,7 +11912,7 @@ + + */ + -+/* $Id: apc_sem.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_sem.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_SEM_H +#define APC_SEM_H @@ -11358,14 +11937,103 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_shm.c -@@ -0,0 +1,114 @@ +diff -Naur a/ext/apc/apc_serializer.h b/ext/apc/apc_serializer.h +--- a/ext/apc/apc_serializer.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_serializer.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,84 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.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. | ++ +----------------------------------------------------------------------+ ++ | Authors: Gopal Vijayaraghavan | ++ +----------------------------------------------------------------------+ ++ ++ */ ++ ++/* $Id: $ */ ++ ++#ifndef APC_SERIALIZER_H ++#define APC_SERIALIZER_H ++ ++/* this is a shipped .h file, do not include any other header in this file */ ++#define APC_SERIALIZER_NAME(module) module##_apc_serializer ++#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer ++ ++#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC ++#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC ++ ++typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS); ++typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS); ++ ++typedef int (*apc_register_serializer_t)(const char* name, ++ apc_serialize_t serialize, ++ apc_unserialize_t unserialize, ++ void *config TSRMLS_DC); ++ ++/* ++ * ABI version for constant hooks. Increment this any time you make any changes ++ * to any function in this file. ++ */ ++#define APC_SERIALIZER_ABI "0" ++#define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI ++ ++#if !defined(APC_UNUSED) ++# if defined(__GNUC__) ++# define APC_UNUSED __attribute__((unused)) ++# else ++# define APC_UNUSED ++# endif ++#endif ++ ++static APC_UNUSED int apc_register_serializer(const char* name, ++ apc_serialize_t serialize, ++ apc_unserialize_t unserialize, ++ void *config TSRMLS_DC) ++{ ++ zval apc_magic_constant; ++ int retval = 0; ++ ++ /* zend_get_constant will return 1 on success, otherwise apc_magic_constant wouldn't be touched at all */ ++ if (zend_get_constant(APC_SERIALIZER_CONSTANT, sizeof(APC_SERIALIZER_CONSTANT)-1, &apc_magic_constant TSRMLS_CC)) { ++ apc_register_serializer_t register_func = (apc_register_serializer_t)(Z_LVAL(apc_magic_constant)); ++ if(register_func) { ++ retval = register_func(name, serialize, unserialize, NULL TSRMLS_CC); ++ } ++ zval_dtor(&apc_magic_constant); ++ } ++ ++ return retval; ++} ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff -Naur a/ext/apc/apc_shm.c b/ext/apc/apc_shm.c +--- a/ext/apc/apc_shm.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_shm.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,116 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11389,7 +12057,7 @@ + + */ + -+/* $Id: apc_shm.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_shm.c 307259 2011-01-08 12:05:24Z gopalv $ */ + +#include "apc_shm.h" +#include "apc.h" @@ -11430,7 +12098,7 @@ + shmctl(shmid, IPC_RMID, 0); +} + -+apc_segment_t apc_shm_attach(int shmid TSRMLS_DC) ++apc_segment_t apc_shm_attach(int shmid, size_t size TSRMLS_DC) +{ + apc_segment_t segment; /* shm segment */ + @@ -11446,6 +12114,8 @@ + +#endif + ++ segment.size = size; ++ + /* + * We set the shmid for removal immediately after attaching to it. The + * segment won't disappear until all processes have detached from it. @@ -11475,14 +12145,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_shm.h +diff -Naur a/ext/apc/apc_shm.h b/ext/apc/apc_shm.h +--- a/ext/apc/apc_shm.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_shm.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,56 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11505,7 +12176,7 @@ + + */ + -+/* $Id: apc_shm.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_shm.h 307259 2011-01-08 12:05:24Z gopalv $ */ + +#ifndef APC_SHM_H +#define APC_SHM_H @@ -11521,7 +12192,7 @@ + +extern int apc_shm_create(int proj, size_t size TSRMLS_DC); +extern void apc_shm_destroy(int shmid); -+extern apc_segment_t apc_shm_attach(int shmid TSRMLS_DC); ++extern apc_segment_t apc_shm_attach(int shmid, size_t size TSRMLS_DC); +extern void apc_shm_detach(apc_segment_t* segment TSRMLS_DC); + +#endif @@ -11534,14 +12205,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_signal.c +diff -Naur a/ext/apc/apc_signal.c b/ext/apc/apc_signal.c +--- a/ext/apc/apc_signal.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_signal.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,197 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11563,7 +12235,7 @@ + All other licensing and usage conditions are those of the PHP Group. + */ + -+ /* $Id: apc_signal.c 302175 2010-08-13 06:20:28Z kalle $ */ ++ /* $Id: apc_signal.c 307048 2011-01-03 23:53:17Z kalle $ */ + + /* Allows apc to install signal handlers and maintain signalling + to already registered handlers. Registers all signals that @@ -11734,14 +12406,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_signal.h +diff -Naur a/ext/apc/apc_signal.h b/ext/apc/apc_signal.h +--- a/ext/apc/apc_signal.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_signal.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,51 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11756,7 +12429,7 @@ + + */ + -+/* $Id: apc_signal.h 300986 2010-07-04 14:41:33Z felipe $ */ ++/* $Id: apc_signal.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_SIGNAL_H +#define APC_SIGNAL_H @@ -11788,14 +12461,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_sma.c +diff -Naur a/ext/apc/apc_sma.c b/ext/apc/apc_sma.c +--- a/ext/apc/apc_sma.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_sma.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,765 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11819,7 +12493,7 @@ + + */ + -+/* $Id: apc_sma.c 305260 2010-11-10 19:23:02Z gopalv $ */ ++/* $Id: apc_sma.c 309489 2011-03-21 00:00:54Z pajoye $ */ + +#include "apc_sma.h" +#include "apc.h" @@ -11970,7 +12644,7 @@ +#endif + +/* {{{ sma_allocate: tries to allocate at least size bytes in a segment */ -+static size_t sma_allocate(sma_header_t* header, size_t size, size_t fragment, size_t *allocated) ++static APC_HOTSPOT size_t sma_allocate(sma_header_t* header, size_t size, size_t fragment, size_t *allocated) +{ + void* shmaddr; /* header of shared memory segment */ + block_t* prv; /* block prior to working block */ @@ -12067,7 +12741,7 @@ +/* }}} */ + +/* {{{ sma_deallocate: deallocates the block at the given offset */ -+static size_t sma_deallocate(void* shmaddr, size_t offset) ++static APC_HOTSPOT size_t sma_deallocate(void* shmaddr, size_t offset) +{ + sma_header_t* header; /* header of shared memory segment */ + block_t* cur; /* the new block to insert */ @@ -12164,7 +12838,7 @@ + sma_segments[i] = apc_mmap(mmap_file_mask, sma_segsize TSRMLS_CC); + if(sma_numseg != 1) memcpy(&mmap_file_mask[strlen(mmap_file_mask)-6], "XXXXXX", 6); +#else -+ sma_segments[i] = apc_shm_attach(apc_shm_create(i, sma_segsize TSRMLS_CC) TSRMLS_CC); ++ sma_segments[i] = apc_shm_attach(apc_shm_create(i, sma_segsize TSRMLS_CC), sma_segsize TSRMLS_CC); +#endif + + sma_segments[i].size = sma_segsize; @@ -12292,7 +12966,7 @@ + /* I've tried being nice, but now you're just asking for it */ + if(!nuked) { + apc_cache->expunge_cb(apc_cache, (n+fragment) TSRMLS_CC); -+ apc_user_cache->expunge_cb(apc_cache, (n+fragment) TSRMLS_CC); ++ apc_user_cache->expunge_cb(apc_user_cache, (n+fragment) TSRMLS_CC); + nuked = 1; + goto restart; + } @@ -12486,7 +13160,7 @@ +#endif + + } -+ UNLOCK(SMA_LCK(i)); ++ RDUNLOCK(SMA_LCK(i)); + } + + return info; @@ -12556,14 +13230,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_sma.h +diff -Naur a/ext/apc/apc_sma.h b/ext/apc/apc_sma.h +--- a/ext/apc/apc_sma.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_sma.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,103 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12586,7 +13261,7 @@ + + */ + -+/* $Id: apc_sma.h 303274 2010-09-11 14:31:32Z iliaa $ */ ++/* $Id: apc_sma.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_SMA_H +#define APC_SMA_H @@ -12662,14 +13337,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_spin.c +diff -Naur a/ext/apc/apc_spin.c b/ext/apc/apc_spin.c +--- a/ext/apc/apc_spin.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_spin.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,66 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12684,7 +13360,7 @@ + + */ + -+/* $Id: apc_spin.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_spin.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc_spin.h" + @@ -12731,14 +13407,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_spin.h +diff -Naur a/ext/apc/apc_spin.h b/ext/apc/apc_spin.h +--- a/ext/apc/apc_spin.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_spin.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12753,7 +13430,7 @@ + + */ + -+/* $Id: apc_spin.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_spin.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_SPIN_H +#define APC_SPIN_H @@ -12782,14 +13459,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_stack.c +diff -Naur a/ext/apc/apc_stack.c b/ext/apc/apc_stack.c +--- a/ext/apc/apc_stack.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_stack.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,106 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12812,7 +13490,7 @@ + + */ + -+/* $Id: apc_stack.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_stack.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc.h" +#include "apc_stack.h" @@ -12891,14 +13569,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_stack.h +diff -Naur a/ext/apc/apc_stack.h b/ext/apc/apc_stack.h +--- a/ext/apc/apc_stack.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_stack.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,58 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12922,7 +13601,7 @@ + + */ + -+/* $Id: apc_stack.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: apc_stack.h 307048 2011-01-03 23:53:17Z kalle $ */ + +#ifndef APC_STACK_H +#define APC_STACK_H @@ -12952,14 +13631,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_string.c -@@ -0,0 +1,247 @@ +diff -Naur a/ext/apc/apc_string.c b/ext/apc/apc_string.c +--- a/ext/apc/apc_string.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_string.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,261 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12982,7 +13662,7 @@ + + */ + -+/* $Id: $ */ ++/* $Id: apc_string.c 326089 2012-06-11 04:29:57Z rasmus $ */ + +#include "apc.h" +#include "apc_globals.h" @@ -12991,6 +13671,7 @@ + +#ifdef ZEND_ENGINE_2_4 + ++#ifndef ZTS +typedef struct _apc_interned_strings_data_t { + char *interned_strings_start; + char *interned_strings_end; @@ -13005,11 +13686,11 @@ + +static char *old_interned_strings_start; +static char *old_interned_strings_end; -+static char *(*old_new_interned_string)(char *str, int len, int free_src TSRMLS_DC); ++static const char *(*old_new_interned_string)(const char *str, int len, int free_src TSRMLS_DC); +static void (*old_interned_strings_snapshot)(TSRMLS_D); +static void (*old_interned_strings_restore)(TSRMLS_D); + -+static char *apc_dummy_new_interned_string_for_php(char *str, int len, int free_src TSRMLS_DC) ++static const char *apc_dummy_new_interned_string_for_php(const char *str, int len, int free_src TSRMLS_DC) +{ + return str; +} @@ -13021,9 +13702,11 @@ +static void apc_dummy_interned_strings_restore_for_php(TSRMLS_D) +{ +} ++#endif + -+char *apc_new_interned_string(char *arKey, int nKeyLength TSRMLS_DC) ++const char *apc_new_interned_string(const char *arKey, int nKeyLength TSRMLS_DC) +{ ++#ifndef ZTS + ulong h; + uint nIndex; + Bucket *p; @@ -13045,17 +13728,18 @@ + p = p->pNext; + } + -+ if (APCSG(interned_strings_top) + ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength) >= ++ if (APCSG(interned_strings_top) + ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength + 1) >= + APCSG(interned_strings_end)) { + /* no memory */ + return NULL; + } + + p = (Bucket *) APCSG(interned_strings_top); -+ APCSG(interned_strings_top) += ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength); ++ APCSG(interned_strings_top) += ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength + 1); + + p->arKey = (char*)(p+1); + memcpy(p->arKey, arKey, nKeyLength); ++ ((char *)p->arKey)[nKeyLength] = '\0'; + p->nKeyLength = nKeyLength; + p->h = h; + p->pData = &p->pDataPtr; @@ -13081,8 +13765,12 @@ + APCSG(interned_strings).nNumOfElements++; + + return p->arKey; ++#else ++ return zend_new_interned_string(arKey, nKeyLength, 0 TSRMLS_CC); ++#endif +} + ++#ifndef ZTS +static void apc_copy_internal_strings(TSRMLS_D) +{ + Bucket *p, *q; @@ -13103,6 +13791,10 @@ + p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); + } + ++ if (ce->name) { ++ ce->name = apc_new_interned_string(ce->name, ce->name_length+1 TSRMLS_CC); ++ } ++ + q = ce->properties_info.pListHead; + while (q) { + zend_property_info *info = (zend_property_info*)(q->pData); @@ -13151,6 +13843,7 @@ + int count = APCG(shm_strings_buffer) / (sizeof(Bucket) + sizeof(Bucket*) * 2); + + apc_interned_strings_data = (apc_interned_strings_data_t*) apc_sma_malloc(APCG(shm_strings_buffer) TSRMLS_CC); ++ memset((void *)apc_interned_strings_data, 0, APCG(shm_strings_buffer)); + + CREATE_LOCK(APCSG(lock)); + @@ -13191,6 +13884,7 @@ + + DESTROY_LOCK(APCSG(lock)); +} ++#endif + +#endif + @@ -13202,14 +13896,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_string.h -@@ -0,0 +1,49 @@ +diff -Naur a/ext/apc/apc_string.h b/ext/apc/apc_string.h +--- a/ext/apc/apc_string.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_string.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,51 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -13232,17 +13927,19 @@ + + */ + -+/* $Id: $ */ ++/* $Id: apc_string.h 324145 2012-03-12 11:38:28Z pajoye $ */ + +#ifndef APC_STRING +#define APC_STRING + +#include "apc.h" + ++#ifndef ZTS +void apc_interned_strings_init(TSRMLS_D); +void apc_interned_strings_shutdown(TSRMLS_D); ++#endif + -+char *apc_new_interned_string(char *arKey, int nKeyLength TSRMLS_DC); ++const char *apc_new_interned_string(const char *arKey, int nKeyLength TSRMLS_DC); + +#endif + @@ -13254,14 +13951,230 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_zend.c +diff -Naur a/ext/apc/apc_windows_srwlock_kernel.c b/ext/apc/apc_windows_srwlock_kernel.c +--- a/ext/apc/apc_windows_srwlock_kernel.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_windows_srwlock_kernel.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,133 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.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. | ++ +----------------------------------------------------------------------+ ++ | Authors: Pierre Joye | ++ +----------------------------------------------------------------------+ ++ */ ++/* $Id$ */ ++/* ++ These APIs are not actually exposed nor documented. But should work fine ++ from a binary as available since XP without signature changes. ++*/ ++/* ++TODOs: ++non blocking could be possible using the fWait argument (to 0). However ++I'm not sure whether the wait handlers is actually implemented in all ++supported platforms (xp+). could be enabled later once really tested. ++ */ ++/* $Id: $ */ ++ ++#include ++ ++#ifdef APC_SRWLOCK_KERNEL ++#include "apc_windows_srwlock_kernel.h" ++ ++/* ++For references: ++void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl); ++void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl); ++BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl, BYTE fWait); ++BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait); ++void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl); ++*/ ++typedef void (WINAPI *tRtlInitializeResource)(LPRTL_RWLOCK rwl); ++typedef void (WINAPI *tRtlDeleteResource)(LPRTL_RWLOCK rwl); ++typedef BYTE (WINAPI *tRtlAcquireResourceExclusive)(LPRTL_RWLOCK rwl, BYTE fWait); ++typedef BYTE (WINAPI *tRtlAcquireResourceShared)(LPRTL_RWLOCK rwl, BYTE fWait); ++typedef void (WINAPI *tRtlReleaseResource)(LPRTL_RWLOCK rwl); ++typedef void (WINAPI *tRtlDumpResource)(LPRTL_RWLOCK rwl); ++ ++tRtlInitializeResource pRtlInitializeResource = 0; ++tRtlDeleteResource pRtlDeleteResource = 0; ++tRtlAcquireResourceExclusive pRtlAcquireResourceExclusive = 0; ++tRtlAcquireResourceShared pRtlAcquireResourceShared = 0; ++tRtlReleaseResource pRtlReleaseResource = 0; ++tRtlDumpResource pRtlDumpResource = 0; ++ ++HINSTANCE ntdll; ++ ++void apc_windows_cs_status(apc_windows_cs_rwlock_t *lock ); ++apc_windows_cs_rwlock_t *apc_windows_cs_create(apc_windows_cs_rwlock_t *lock TSRMLS_DC) ++{ ++ ntdll = LoadLibrary("ntdll.dll"); ++ if (ntdll == 0) { ++ return NULL; ++ } ++ ++ pRtlInitializeResource = (tRtlInitializeResource) GetProcAddress(ntdll, "RtlInitializeResource"); ++ pRtlDeleteResource = (tRtlDeleteResource) GetProcAddress(ntdll, "RtlDeleteResource"); ++ pRtlAcquireResourceExclusive = (tRtlAcquireResourceExclusive) GetProcAddress(ntdll, "RtlAcquireResourceExclusive"); ++ pRtlAcquireResourceShared = (tRtlAcquireResourceShared) GetProcAddress(ntdll, "RtlAcquireResourceShared"); ++ pRtlReleaseResource = (tRtlReleaseResource) GetProcAddress(ntdll, "RtlReleaseResource"); ++ pRtlDumpResource = (tRtlReleaseResource) GetProcAddress(ntdll, "RtlDumpResource"); ++ if (pRtlInitializeResource == 0 || pRtlDeleteResource == 0 || pRtlAcquireResourceExclusive == 0 || ++ pRtlAcquireResourceShared == 0 || pRtlReleaseResource == 0 || pRtlDumpResource == 0) { ++ return NULL; ++ } ++ pRtlInitializeResource(lock); ++ return lock; ++} ++ ++void apc_windows_cs_destroy(apc_windows_cs_rwlock_t *lock) ++{ ++ __try ++ { ++ pRtlDeleteResource(lock); ++ } ++ __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? ++ EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) ++ { ++ /* Ignore exception (resource was freed during shutdown of another thread) */ ++ } ++ FreeLibrary(ntdll); ++ return; ++} ++ ++void apc_windows_cs_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC) ++{ ++ pRtlAcquireResourceExclusive(lock, 1); ++} ++ ++void apc_windows_cs_rdlock(apc_windows_cs_rwlock_t *lock TSRMLS_DC) ++{ ++ pRtlAcquireResourceShared(lock, 1); ++} ++ ++void apc_windows_cs_unlock_rd(apc_windows_cs_rwlock_t *lock TSRMLS_DC) ++{ ++ pRtlReleaseResource(lock); ++} ++ ++void apc_windows_cs_unlock_wr(apc_windows_cs_rwlock_t *lock TSRMLS_DC) ++{ ++ pRtlReleaseResource(lock); ++} ++ ++/* debugging purposes, output using trace msgs */ ++void apc_windows_cs_status(apc_windows_cs_rwlock_t *lock) ++{ ++ pRtlDumpResource(lock); ++ return; ++} ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff -Naur a/ext/apc/apc_windows_srwlock_kernel.h b/ext/apc/apc_windows_srwlock_kernel.h +--- a/ext/apc/apc_windows_srwlock_kernel.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_windows_srwlock_kernel.h 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,74 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2011 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.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. | ++ +----------------------------------------------------------------------+ ++ | Authors: Pierre Joye | ++ +----------------------------------------------------------------------+ ++ */ ++/* $Id$ */ ++ ++#ifndef APC_WINDOWS_CS_RWLOCK_H ++#define APC_WINDOWS_CS_RWLOCK_H ++ ++#include "apc.h" ++ ++#ifdef APC_SRWLOCK_KERNEL ++ ++typedef struct _RTL_RWLOCK { ++ RTL_CRITICAL_SECTION rtlCS; ++ ++ HANDLE hSharedReleaseSemaphore; ++ UINT uSharedWaiters; ++ ++ HANDLE hExclusiveReleaseSemaphore; ++ UINT uExclusiveWaiters; ++ ++ INT iNumberActive; ++ HANDLE hOwningThreadId; ++ DWORD dwTimeoutBoost; ++ PVOID pDebugInfo; ++} RTL_RWLOCK, *LPRTL_RWLOCK; ++ ++#define apc_windows_cs_rwlock_t RTL_RWLOCK ++ ++struct apc_windows_cs_rwlock_t { ++ CRITICAL_SECTION cs; ++ LONG writers_waiting_count; ++ LONG readers_waiting_count; ++ DWORD active_writers_readers_flag; ++ HANDLE ready_to_read; ++ HANDLE ready_to_write; ++ DWORD reader_races_lost; ++}; ++ ++apc_windows_cs_rwlock_t *apc_windows_cs_create(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++void apc_windows_cs_destroy(apc_windows_cs_rwlock_t *lock); ++void apc_windows_cs_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++void apc_windows_cs_rdlock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++void apc_windows_cs_unlock_rd(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++void apc_windows_cs_unlock_wr(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++# if NONBLOCKING_LOCK_AVAILABLE==1 /* Only in win7/2008 */ ++zend_bool apc_pthreadrwlock_nonblocking_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); ++# endif ++#endif ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +diff -Naur a/ext/apc/apc_zend.c b/ext/apc/apc_zend.c +--- a/ext/apc/apc_zend.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_zend.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,271 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -13284,7 +14197,7 @@ + + */ + -+/* $Id: apc_zend.c 303426 2010-09-16 16:39:08Z iliaa $ */ ++/* $Id: apc_zend.c 307048 2011-01-03 23:53:17Z kalle $ */ + +#include "apc_zend.h" +#include "apc_globals.h" @@ -13528,14 +14441,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/apc_zend.h +diff -Naur a/ext/apc/apc_zend.h b/ext/apc/apc_zend.h +--- a/ext/apc/apc_zend.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/apc_zend.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,191 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -13558,7 +14472,7 @@ + + */ + -+/* $Id: apc_zend.h 303464 2010-09-17 12:19:29Z gopalv $ */ ++/* $Id: apc_zend.h 326712 2012-07-19 21:33:27Z rasmus $ */ + +#ifndef APC_ZEND_H +#define APC_ZEND_H @@ -13673,7 +14587,7 @@ +# if PHP_MAJOR_VERSION >= 6 +# define APC_OPCODE_HANDLER_COUNT ((25 * 152) + 1) +# elif defined(ZEND_ENGINE_2_4) -+# define APC_OPCODE_HANDLER_COUNT ((25 * 157) + 1) /* 3 new opcodes in 5.4? - separate, bind_trais, add_trait */ ++# define APC_OPCODE_HANDLER_COUNT ((25 * 159) + 1) /* 5 new opcodes in 5.4 - qm_assign_var, jmp_set_var, separate, bind_trais, add_trait */ +# elif PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 +# define APC_OPCODE_HANDLER_COUNT ((25 * 154) + 1) /* 3 new opcodes in 5.3 - unused, lambda, jmp_set */ +# else @@ -13722,8 +14636,9 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/CHANGELOG +diff -Naur a/ext/apc/CHANGELOG b/ext/apc/CHANGELOG +--- a/ext/apc/CHANGELOG 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/CHANGELOG 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,249 @@ + +3.1.2 : 2008-12-12 @@ -13974,11 +14889,12 @@ + +1.0.1: +- added optional file modification time check [djc 2001-01-12] ---- /dev/null -+++ b/ext/apc/config.m4 -@@ -0,0 +1,246 @@ +diff -Naur a/ext/apc/config.m4 b/ext/apc/config.m4 +--- a/ext/apc/config.m4 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/config.m4 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,404 @@ +dnl -+dnl $Id: config.m4 304101 2010-10-05 14:37:36Z kalle $ ++dnl $Id: config.m4 326700 2012-07-19 11:56:57Z ab $ +dnl + +PHP_ARG_ENABLE(apc, whether to enable APC support, @@ -13987,7 +14903,7 @@ +AC_ARG_ENABLE(apc-debug, +[ --enable-apc-debug Enable APC debugging], +[ -+ PHP_APC_DEBUG=yes ++ PHP_APC_DEBUG=$enableval +], +[ + PHP_APC_DEBUG=no @@ -14074,7 +14990,7 @@ + return -1; + } + -+ puts("pthread mutex's are supported!"); ++ puts("pthread mutexs are supported!"); + return 0; + } + ], @@ -14082,7 +14998,7 @@ + PHP_ADD_LIBRARY(pthread) + ], + [ dnl -Failure- -+ AC_MSG_WARN([It doesn't appear that pthread mutex's are supported on your system]) ++ AC_MSG_WARN([It doesn't appear that pthread mutexes are supported on your system]) + PHP_APC_PTHREADMUTEX=no + ], + [ @@ -14092,6 +15008,93 @@ + LIBS="$orig_LIBS" +fi + ++AC_MSG_CHECKING(whether we should use pthread read/write locking) ++AC_ARG_ENABLE(apc-pthreadrwlocks, ++[ --enable-apc-pthreadrwlocks ++ Enable pthread read/write locking ], ++[ ++ PHP_APC_PTHREADRWLOCK=$enableval ++ AC_MSG_RESULT($enableval) ++], ++[ ++ PHP_APC_PTHREADRWLOCK=no ++ AC_MSG_RESULT(no) ++]) ++ ++if test "$PHP_APC_PTHREADRWLOCK" != "no"; then ++ orig_LIBS="$LIBS" ++ LIBS="$LIBS -lpthread" ++ AC_TRY_RUN( ++ [ ++ #include ++ #include ++ main() { ++ pthread_rwlock_t rwlock; ++ pthread_rwlockattr_t attr; ++ ++ if(pthread_rwlockattr_init(&attr)) { ++ puts("Unable to initialize pthread attributes (pthread_rwlockattr_init)."); ++ return -1; ++ } ++ if(pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) { ++ puts("Unable to set PTHREAD_PROCESS_SHARED (pthread_rwlockattr_setpshared), your system may not support shared rwlock's."); ++ return -1; ++ } ++ if(pthread_rwlock_init(&rwlock, &attr)) { ++ puts("Unable to initialize the rwlock (pthread_rwlock_init)."); ++ return -1; ++ } ++ if(pthread_rwlockattr_destroy(&attr)) { ++ puts("Unable to destroy rwlock attributes (pthread_rwlockattr_destroy)."); ++ return -1; ++ } ++ if(pthread_rwlock_destroy(&rwlock)) { ++ puts("Unable to destroy rwlock (pthread_rwlock_destroy)."); ++ return -1; ++ } ++ ++ puts("pthread rwlocks are supported!"); ++ return 0; ++ } ++ ], ++ [ dnl -Success- ++ PHP_ADD_LIBRARY(pthread) ++ APC_CFLAGS="-D_GNU_SOURCE" ++ ], ++ [ dnl -Failure- ++ AC_MSG_WARN([It doesn't appear that pthread rwlocks are supported on your system]) ++ PHP_APC_PTHREADRWLOCK=no ++ ], ++ [ ++ PHP_ADD_LIBRARY(pthread) ++ ] ++ ) ++ LIBS="$orig_LIBS" ++fi ++ ++ AC_CACHE_CHECK([whether the target compiler supports builtin atomics], PHP_cv_APC_GCC_ATOMICS, [ ++ ++ AC_TRY_LINK([],[ ++ int foo = 0; ++ __sync_fetch_and_add(&foo, 1); ++ __sync_bool_compare_and_swap(&foo, 0, 1); ++ return __sync_fetch_and_add(&foo, 1); ++ ], ++ [PHP_cv_APC_GCC_ATOMICS=yes], ++ [PHP_cv_APC_GCC_ATOMICS=no]) ++ ]) ++ ++ if test "x${PHP_cv_APC_GCC_ATOMICS}" != "xno"; then ++ AC_DEFINE(HAVE_ATOMIC_OPERATIONS, 1, ++ [Define this if your target compiler supports builtin atomics]) ++ else ++ if test "$PHP_APC_PTHREADRWLOCK" != "no"; then ++ AC_MSG_WARN([Disabling pthread rwlocks, because of missing atomic operations]) ++ dnl - fall back would most likely be pthread mutexes ++ PHP_APC_PTHREADRWLOCK=no ++ fi ++ fi ++ +AC_MSG_CHECKING(whether we should use spin locks) +AC_ARG_ENABLE(apc-spinlocks, +[ --enable-apc-spinlocks @@ -14105,6 +15108,7 @@ + AC_MSG_RESULT(no) +]) + ++ +AC_MSG_CHECKING(whether we should enable memory protection) +AC_ARG_ENABLE(apc-memprotect, +[ --enable-apc-memprotect @@ -14129,6 +15133,8 @@ + AC_DEFINE(APC_SEM_LOCKS, 1, [ ]) + elif test "$PHP_APC_SPINLOCKS" != "no"; then + AC_DEFINE(APC_SPIN_LOCKS, 1, [ ]) ++ elif test "$PHP_APC_PTHREADRWLOCK" != "no"; then ++ AC_DEFINE(APC_PTHREADRW_LOCKS, 1, [ ]) + elif test "$PHP_APC_PTHREADMUTEX" != "no"; then + AC_DEFINE(APC_PTHREADMUTEX_LOCKS, 1, [ ]) + else @@ -14204,6 +15210,7 @@ + apc_sem.c \ + apc_shm.c \ + apc_pthreadmutex.c \ ++ apc_pthreadrwlock.c \ + apc_spin.c \ + pgsql_s_lock.c \ + apc_sma.c \ @@ -14220,21 +15227,90 @@ + PHP_NEW_EXTENSION(apc, $apc_sources, $ext_shared,, \\$(APC_CFLAGS)) + PHP_SUBST(APC_SHARED_LIBADD) + PHP_SUBST(APC_CFLAGS) ++ PHP_INSTALL_HEADERS(ext/apc, [apc_serializer.h]) + AC_DEFINE(HAVE_APC, 1, [ ]) +fi + ---- /dev/null -+++ b/ext/apc/config.w32 -@@ -0,0 +1,48 @@ -+// $Id: config.w32 305410 2010-11-16 16:47:18Z pajoye $ -+// vim:ft=javascript ++PHP_ARG_ENABLE(coverage, whether to include code coverage symbols, ++[ --enable-coverage DEVELOPERS ONLY!!], no, no) + ++if test "$PHP_COVERAGE" = "yes"; then ++ ++ if test "$GCC" != "yes"; then ++ AC_MSG_ERROR([GCC is required for --enable-coverage]) ++ fi ++ ++ dnl Check if ccache is being used ++ case `$php_shtool path $CC` in ++ *ccache*[)] gcc_ccache=yes;; ++ *[)] gcc_ccache=no;; ++ esac ++ ++ if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then ++ AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) ++ fi ++ ++ lcov_version_list="1.5 1.6 1.7 1.9" ++ ++ AC_CHECK_PROG(LCOV, lcov, lcov) ++ AC_CHECK_PROG(GENHTML, genhtml, genhtml) ++ PHP_SUBST(LCOV) ++ PHP_SUBST(GENHTML) ++ ++ if test "$LCOV"; then ++ AC_CACHE_CHECK([for lcov version], php_cv_lcov_version, [ ++ php_cv_lcov_version=invalid ++ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` #' ++ for lcov_check_version in $lcov_version_list; do ++ if test "$lcov_version" = "$lcov_check_version"; then ++ php_cv_lcov_version="$lcov_check_version (ok)" ++ fi ++ done ++ ]) ++ else ++ lcov_msg="To enable code coverage reporting you must have one of the following LCOV versions installed: $lcov_version_list" ++ AC_MSG_ERROR([$lcov_msg]) ++ fi ++ ++ case $php_cv_lcov_version in ++ ""|invalid[)] ++ lcov_msg="You must have one of the following versions of LCOV: $lcov_version_list (found: $lcov_version)." ++ AC_MSG_ERROR([$lcov_msg]) ++ LCOV="exit 0;" ++ ;; ++ esac ++ ++ if test -z "$GENHTML"; then ++ AC_MSG_ERROR([Could not find genhtml from the LCOV package]) ++ fi ++ ++ PHP_ADD_MAKEFILE_FRAGMENT ++ ++ dnl Remove all optimization flags from CFLAGS ++ changequote({,}) ++ CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'` ++ CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'` ++ changequote([,]) ++ ++ dnl Add the special gcc flags ++ CFLAGS="$CFLAGS -O0 -ggdb -fprofile-arcs -ftest-coverage" ++ CXXFLAGS="$CXXFLAGS -ggdb -O0 -fprofile-arcs -ftest-coverage" ++fi ++dnl vim: set ts=2 +diff -Naur a/ext/apc/config.w32 b/ext/apc/config.w32 +--- a/ext/apc/config.w32 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/config.w32 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,60 @@ ++// $Id: config.w32 309203 2011-03-14 06:47:16Z pajoye $ ++// vim:ft=javascript + +ARG_ENABLE('apc', 'Whether to enable APC support', 'no'); +ARG_ENABLE('apc-debug', 'Whether to enable APC debugging', 'no'); +ARG_ENABLE('apc-filehits', 'Whether to enable cache request file info', 'no'); +ARG_ENABLE('apc-spinlocks', 'Whether to use spin locks (experimental)', 'no'); +ARG_ENABLE('apc-memprotect', 'Whether to enable memory protection (experimental)', 'no'); ++ARG_ENABLE('apc-srwlock-native', 'Whether to use SRWLOCK locks native (win7/2008 only)', 'no'); ++ARG_ENABLE('apc-srwlock-kernel', 'Whether to use SRWLOCK locks (loaded at runtime)', 'no'); + +if(PHP_APC != 'no') +{ @@ -14258,26 +15334,37 @@ + AC_DEFINE('APC_MEMPROTECT', 1); + } + -+ if(PHP_APC_SPINLOCKS != 'no') -+ { -+ AC_DEFINE('APC_SPIN_LOCKS', 1); -+ ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); ++ if(PHP_APC_SRWLOCK_NATIVE != 'no') { ++ AC_DEFINE('APC_SRWLOCK_NATIVE', 1); ++ } else { ++ if(PHP_APC_SRWLOCK_KERNEL != 'no') { ++ AC_DEFINE('APC_SRWLOCK_KERNEL', 1); ++ ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); + -+ apc_sources += ' apc_spin.c pgsql_s_lock.c'; -+ } -+ else -+ { -+ AC_DEFINE('APC_FCNTL_LOCKS', 1); ++ apc_sources += ' apc_windows_srwlock_kernel.c'; ++ } else { ++ if(PHP_APC_SPINLOCKS != 'no') { ++ AC_DEFINE('APC_SPIN_LOCKS', 1); ++ ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); ++ ++ apc_sources += ' apc_spin.c pgsql_s_lock.c'; ++ } else { ++ AC_DEFINE('APC_FCNTL_LOCKS', 1); ++ } ++ } + } + + AC_DEFINE('HAVE_APC', 1); ++ AC_DEFINE('HAVE_ATOMIC_OPERATIONS', 1); ++ ++ PHP_INSTALL_HEADERS("ext/apc", "apc_serializer.h"); + + EXTENSION('apc', apc_sources); +} -\ No newline at end of file ---- /dev/null -+++ b/ext/apc/INSTALL -@@ -0,0 +1,400 @@ +diff -Naur a/ext/apc/INSTALL b/ext/apc/INSTALL +--- a/ext/apc/INSTALL 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/INSTALL 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,407 @@ +Installation Instructions for APC +--------------------------------- + @@ -14303,7 +15390,7 @@ +---------------------------------------------- + extension=apc.so + apc.enabled=1 -+ apc.shm_size=128 ++ apc.shm_size=128M + apc.ttl=7200 + apc.user_ttl=7200 + apc.enable_cli=1 @@ -14497,8 +15584,9 @@ + apc.shm_size The size of each shared memory segment in MB. + By default, some systems (including most BSD + variants) have very low limits on the size of a -+ shared memory segment. ++ shared memory segment. M/G suffixes must be used. + (Default: 30) ++ + + apc.optimization This option has been deprecated. + (Default: 0) @@ -14678,12 +15766,19 @@ + Optimize include_once and require_once calls and avoid the + expensive system calls used. + (Default: 0) ---- /dev/null -+++ b/ext/apc/LICENSE ++ ++ apc.serializer ++ Defines which serializer should be used. Default is the ++ standard PHP serializer. Other can be used without having ++ to re compile apc, like igbinary for example. ++ (apc.serializer=igbinary) +diff -Naur a/ext/apc/LICENSE b/ext/apc/LICENSE +--- a/ext/apc/LICENSE 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/LICENSE 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- + The PHP License, version 3.01 -+Copyright (c) 1999 - 2010 The PHP Group. All rights reserved. ++Copyright (c) 1999 - 2011 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without @@ -14749,8 +15844,9 @@ + +PHP includes the Zend Engine, freely available at +. ---- /dev/null -+++ b/ext/apc/NOTICE +diff -Naur a/ext/apc/NOTICE b/ext/apc/NOTICE +--- a/ext/apc/NOTICE 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/NOTICE 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,43 @@ +This is the NOTICE file that holds acknowledgements and stuff. + @@ -14795,844 +15891,15 @@ + Angel Li diffs for ANSI comment compliance + Christian Rishøj help debugging phplib problems + Sascha Schumann memory error bug fix ---- /dev/null -+++ b/ext/apc/package.xml -@@ -0,0 +1,827 @@ -+ -+ -+ APC -+ pecl.php.net -+ Alternative PHP Cache -+ APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. -+ -+ Daniel Cowgill -+ dcowgill -+ dan@mail.communityconnect.com -+ no -+ -+ -+ George Schlossnagle -+ gschlossnagle -+ george@omniti.com -+ no -+ -+ -+ Rasmus Lerdorf -+ rasmus -+ rasmus@php.net -+ yes -+ -+ -+ Gopal Vijayaraghavan -+ gopalv -+ gopalv@php.net -+ yes -+ -+ -+ Edin Kadribasic -+ edink -+ edink@emini.dk -+ no -+ -+ -+ Ilia Alshanetsky -+ iliaa -+ ilia@prohost.org -+ yes -+ -+ -+ Marcus Börger -+ helly -+ helly@php.net -+ no -+ -+ -+ Sara Golemon -+ pollita -+ pollita@php.net -+ no -+ -+ -+ Brian Shire -+ shire -+ shire@php.net -+ yes -+ -+ -+ Kalle Sommer Nielsen -+ kalle -+ kalle@php.net -+ yes -+ -+ -+ Pierre Joye -+ pajoye -+ pierre@php.net -+ yes -+ -+ 2010-11-30 -+ -+ -+ 3.1.6 -+ 3.1.0 -+ -+ -+ stable -+ stable -+ -+ PHP License -+ -+- make slam_defense a little more optimistic, allow a thread/process to write to cache in a loop -+- ensure realpaths hit the realpath_cache, in no-stat mode -+- prevent memory starvation, nuke all caches when expunging just one doesn't work -+- fix uploadprogress keylength issues (NUL is part of keylen, pecl bug #20016) -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 5.1.0 -+ -+ -+ 1.4.0 -+ -+ -+ -+ apc -+ -+ -+ -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 2.0.0 -+ 2.0.0 -+ -+ 2003-07-01 -+ -+Complete rework. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 2.0.1 -+ 2.0.0 -+ -+ 2003-07-01 -+ -+Win32 support added. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 2.0.2 -+ 2.0.0 -+ -+ 2004-03-12 -+ -+Fixed non-existant class bug. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.0 -+ 3.0.0 -+ -+ 2005-07-05 -+ -+PHP-5.1 Support and numerous fixes -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.1 -+ 3.0.0 -+ -+ 2005-07-05 -+ -+PHP4 build fix -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.2 -+ 3.0.0 -+ -+ 2005-07-05 -+ -+Default to mmap and add a better error message for shmget failures -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.3 -+ 3.0.0 -+ -+ 2005-07-07 -+ -+Fix compile problem against PHP 5.0.x -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.4 -+ 3.0.0 -+ -+ 2005-07-18 -+ -+Add win32 support from Edin. -+Add --with-apxs switch to work around problem when loading APC into Apache binary compiled with LFS switches -+A couple of other minor fixes. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.5 -+ 3.0.0 -+ -+ 2005-07-27 -+ -+Make it easier for sapis that only populate file_handle->filename to use APC. (Rasmus) -+Support extensions such as bcompiler that need to hook into compile_file. (Val) -+Ralf Becker's apcgui code has now become the default apc.php status page. (Ralf, Rasmus, Ilia) -+Segfault in cache cleanup code (Ilia, Rasmus) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.6 -+ 3.0.0 -+ -+ 2005-07-30 -+ -+Added apc.php to package.xml file. -+Track per-entry memory usage. (Val) -+Various apc.php fixes and enhancements. (Ralf, Ilia, Rasmus) -+fcntl locking robustness fixes. (Rasmus) -+Shared read-locks where possible. (Rasmus) -+Added file_update_protection configuration parameter. (Rasmus) -+Windows ZTS fixes (Frank) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.7 -+ 3.0.0 -+ -+ 2005-08-16 -+ -+Fix to apc.php to show final segment in frag chart. (Ilia) -+A couple of win32 fixes. (Frank) -+Add apc.enable_cli ini directive. (Rasmus) -+Add test cases. (Marcus) -+Fix apc_define_constants() bug - http://pecl.php.net/bugs/5084 (Rasmus) -+Simplify user cache handling by removing the user_cache_stack (Rasmus) -+Fix apc_fetch() memory corruption (Andrei,Rasmus) -+Added apc.max_file_size INI setting that allows exclusion of large files from being cached. Default file size limit, 1 megabyte. (Ilia) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.8 -+ 3.0.0 -+ -+ 2005-08-24 -+ -+Fix invalid free in globals destructor introduced in 3.0.7 (Rasmus) -+Cache corruption fix in cache-full cleanup code (Gopal) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.9 -+ 3.0.0 -+ -+ 2006-03-04 -+ -+Eliminate rand() call when slam_defense is not set (Rasmus) -+Fix for __isset problem (Gopal) -+Rewrite allocator from a "best fit" to a "next fit" algorithm (Rasmus) -+Added a Cache Full counter so we have an idea how many times the segment has filled up causing an expunge (Rasmus) -+Report back the correct number of available bytes in the segment instead of the allocated bytes. (Rasmus) -+Add cache busy flag which is set when an expunge is underway (Rasmus) -+Add automatic serialization of objects in apc_store() (Marcus) -+64-bit .ini flag fix (Rasmus) -+Static members fix (Gopal) -+sma_cleanup() mem leak fix (Rasmus) -+Fix for http://pecl.php.net/bugs/5311 (Rasmus) -+Fix autoglobals JIT bug (Gopal) -+Fix instance bug (Gopal) -+Add a lock cleanup safety net to request shutdown (Rasmus) -+Fix apc.slam_defense edge-case bug (Rasmus) -+User entry memory usage tracking support (Ilia) -+Allow keys used in apc_store/apc_fetch/apc_delete to be binary safe and prevent conflicts between keys that are found at the start of other keys. (Ilia) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.10 -+ 3.0.0 -+ -+ 2006-03-11 -+ -+* Add apc.stat ini flag which defaults to 1. If set to 0, the main script and any fullpath -+ includes will not be stat'ed for any changes. You will have to restart the server if you -+ change anything. This mode increases performance quite a bit, especially if you have a -+ lot of includes. -+ -+* Get rid of the lock safety net hack I added in 3.0.9. It seems to cause more problems -+ than it solves. I'll need to revisit locking and signal handling at some point soon. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.11 -+ 3.0.0 -+ -+ 2006-08-16 -+ -+* Made --enable-apc-mmap the default compile option (for real this time) -+ -+* Add an optional flag to apc_cache_info() and some apc.php tweaks to make it -+ only fetch header information to make it useful when you have tens of -+ thousands of entries. (Brian Shire) -+ -+* 64-bit fixes (George) -+ -+* Don't mix Full Path and Inode keys (George) -+ -+* Override ZEND_INCLUDE_OR_EVAL opcode (when possible) to speed up use of -+ require_once() and include_once() statements. (Sara) -+ -+* Add a non-blocking write_lock for cache inserts. This is a better approach -+ to prevent cache slams and deprecates the slam_defense setting. (Rasmus) -+ -+* A bit of work on the optimizer. (Sara) -+ -+* Various memory issues resolved. (Gopal) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.12 -+ 3.0.0 -+ -+ 2006-09-04 -+ -+* Fix stray debug message -+ -+* Work on the optimizer - still not stable (Gopal, Ilia, Sara) -+ -+* Performance boost - Replace multiple loops over the opcode -+ array with a single loop for copying, jump fixups and auto -+ global pre-fetches. (Gopal) -+ -+* Perform fetch_global checks only in php5 and only if -+ auto_globals_jit is enabled. (Gopal) -+ -+* Fix bug #8579 - scrub php4 classes' function_table and default -+ properties before inserting into cache. (Gopal) -+ -+* Fix bug #8606 - ZEND_FETCH_GLOBAL is not an opcode, but is a -+ op1->type. The opcodes applicable are ZEND_FETCH_R and -+ ZEND_FETCH_W. (Gopal) -+ -+* PHP 5.2 Compatibility (Gopal) -+ -+* Make the include_once override optional - default off (Sara) -+ -+* Fixed crash when apc run in CLI, but enable_cli is off. (Ilia) -+ -+* Ensure that the apc_globals->cache_stack is cleared before the -+ shm cache is destroyed. Fixes segfault for corner-case i.e request -+ shutdown (apc_deactivate) is not called before module shutdown -+ calls (php_apc_shutdown_globals) (Gopal) -+ -+* TSRM fixes (ensure ts_free_id before apc.so is dlclosed) (Gopal) -+ -+* Fix memory leak of apc_cache_info_t->deleted_list (Gopal) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.12p1 -+ 3.0.0 -+ -+ 2006-09-05 -+ -+* The only change here is a trivial PHP 4 build fix. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.12p2 -+ 3.0.0 -+ -+ 2006-09-05 -+ -+* Let's get the version number right. 3.0.12p2 now. -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.13 -+ 3.0.0 -+ -+ 2007-02-24 -+ -+* PHP 5.2 file upload progress tracking support (Rasmus) -+* Pthread mutex and spin locks (Shire) -+* Recursive zval support for apc_fetch/_store (Shire, Gopal) -+* apc.stat_ctime flag for ctime checks (Rasmus) -+* Multiple key fetches with apc_fetch (Shire) -+* Canary checks for shm memory deallocation (Gopal) -+* Add hooks for external optimizer (Shire) -+* Obsolete and remove apc optimizer (Gopal) -+* APC info changes - cache insert rate, hit and miss rates (Shire) -+* Fix apc_load_constants (Gopal) -+* Rewrite dump opcode code to use vld (Gopal) -+* Use apc_[ewn]print functions for error reporting (Shire) -+* Auto global fixes and refactoring (Gopal, Shire) -+* Fix memory leaks in object serialization (Ilia) -+* Memory cleanup code for destructor order (Gopal) -+* Win32 build fixes (Ilia, Wez) -+* ZTS and Php 4 build fixes (Bjori) -+* Add apc_add() function (Rasmus) -+* Add optional limited flag to apc_sma_info() (Rasmus) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.14 -+ 3.0.0 -+ -+ 2007-04-02 -+ -+* Build fix (Shire) -+* Don't hook the upload hook if APC is disabled (Rasmus) -+* Local shadow cache support (Gopal) -+* Avoid uneccessary loops over op_arrays for "known" auto-globals (Gopal) -+* Fix apc_add() to overwrite timed out user entries (Rasmus) -+* Fix double inclusion of files with conditional classes in php4 (Gopal) -+* Allocator fixes to reduce fragmentation (Gopal) -+ -+ -+ -+ -+ stable -+ stable -+ -+ -+ 3.0.15 -+ 3.0.0 -+ -+ 2007-10-18 -+ -+* Eliminate a per-request time() syscall (Rasmus) -+* Added rfc1867 prefix, name, and freq ini options (Shire) -+* Allow deletion of individual user cache entries via apc.php (Sara) -+* Fix overzealous cleanup during RSHUTDOWN (Gopal) -+* Fix memory alignment and locking issues (Gopal) -+* Make apc_compile insert/replace entries (Shire) -+* Make mixed inheritance recompile & cache afresh (Gopal) -+* Make nostat mode search include_path for canonicalization (Gopal) -+* ZTS & other compile fixes (Gopal, Edin, Shire) -+ -+ -+ -+ -+ 3.0.16 -+ 3.0.0 -+ -+ -+ stable -+ stable -+ -+ PHP License -+ 2008-03-26 -+ -+* Fix for longstanding cache-full crash (Christian Seiler) -+ http://news.php.net/php.pecl.dev/4951 for the details -+* Added optional shm unmap on a fatal signal feature (Lucas Nealan) -+* Added PTHREAD_MUTEX_ADAPTIVE_NP option pthread locks (Paul Saab) -+* Minor cleanups (Lucas Nealan) -+* Added configure option to enable apc_cache_info('filehits') (Shire) -+ -+ -+ -+ -+ 3.0.17 -+ 3.0.0 -+ -+ -+ stable -+ stable -+ -+ PHP License -+ 2008-03-29 -+ -+* Crash fixes -+* Fix apc_add() cache expunge bug (Rasmus) -+* Added parameter to apc_fetch to determine success/failure when fetching booleans (shire) -+* Fix misc. memleaks (shire) -+ -+ -+ -+ -+ 3.0.18 -+ 3.0.0 -+ -+ -+ stable -+ stable -+ -+ PHP License -+ 2008-03-29 -+ -+- Revert apc_expunge_cb bug-fix -+- Misc memleaks -+ -+ -+ -+ -+ 3.0.19 -+ 3.0.0 -+ -+ -+ stable -+ stable -+ -+ PHP License -+ 2008-05-15 -+ -+- Safe-mode and fast-cgi fixes -+- Fix double-free of builtin_functions -+- php 5.3 fixes -+ -+ -+ -+ -+ 3.1.1 -+ 3.1.0 -+ -+ -+ beta -+ beta -+ -+ PHP License -+ 2008-12-12 -+ -+- PHP4 compatibilty break -+- apc_pool allocator (Gopal) -+- doubly-linked sma allocator (Shire) -+- php 5.3 gc compatibility (Gopal) -+- APCIterator for easy access (Shire) -+- apc_delete_file (Shire) -+- apc_inc/apc_dec/apc_cas functions (Shire) -+- apc.canonicalize (Gopal) -+- apc.preload_path (Gopal) -+- apc.rfc1867_ttl (Shire) -+- apc.file_md5 (Shire) -+- consolidate locking macros (Shire) -+- remove futex/TSRM locks (Shire) -+- non-blocking semaphore locks (Shire) -+- zval* object rework (Gopal) -+ -+ -+ -+ -+ 3.1.2 -+ 3.1.0 -+ -+ -+ beta -+ beta -+ -+ PHP License -+ 2008-12-12 -+ -+- pecl package.xml/build fixes (bjori) -+ -+ -+ -+ -+ 3.1.3 -+ 3.1.0 -+ -+ -+ beta -+ beta -+ -+ PHP License -+ 2009-08-13 -+ -+- pecl package.xml/build fixes (bjori) -+- 5.3 support + test-cases (Gopal) -+- Lazy loading support (Shire) -+- Fix PCRE module init order issues (Shire) -+- APCIterator fixes (Shire) -+- Cache slam checks (Gopal) -+- ZEND_JMP_SET support (Shire) -+- apc.use_request_time option (shire) -+- apc.php hostname fixes (Shire) -+- memprotect framework (Gopal) -+- Win32 build-fixes (Kalle) -+ -+ -+ -+ -+ 3.1.3p1 -+ 3.1.0 -+ -+ -+ beta -+ beta -+ -+ PHP License -+ 2009-08-14 -+ -+- fix pecl build / package.xml (Gopal) -+ -+ -+ -+ -+ 3.1.4 -+ 3.1.0 -+ -+ -+ beta -+ beta -+ -+ PHP License -+ 2010-08-05 -+ -+- Windows builds may now have filehits and memory protection if enabled (Kalle) -+- Renamed the memory protection configure option to --enable-apc-memprotect (Kalle, Shire) -+- ZTS fixes and optimizations (Kalle, Felipe) -+- Win32 stat support (Pierre, Kalle) -+- Added support for interned strings, run-time caches and Zend Engine 2.4 (Dmitry) -+- Added apc_exists() (Rasmus) -+- Fixed potential XSS in apc.php, CVE-2010-3294 (Pierre, Matt Chapman) -+- Fixed pecl bug #17597 (keys with embedded NUL) (Gopal) -+- Fixed pecl bug #17650 (Fix goto jump offsets) (Gopal) -+- Fixed pecl bug #17527 (Standardized error reporting) (Gopal, Paul Dragoonis) -+- Fixed pecl bug #17089 (Scrub the constant table of all inherited members before caching) (Gopal) -+- Fixed pecl bug #16860 (files can be included more than once even when include/require_once are used) (Pierre) -+- Fixed pecl bug #16717 (apc_fetch dies after 1 hour, regardless of ttl settings) (Kalle) -+- Fixed pecl bug #17597 (apc user cache keys with embedded NULs) (Gopal) -+- Fixed pecl bug #13583 (apc upload progress fixes) (Gopal) -+ -+ -+ -+ -+ 3.1.5 -+ 3.1.0 -+ -+ -+ beta -+ stable -+ -+ PHP License -+ 2010-11-01 -+ -+- Reduce usage of CG(open_files) (mkoppanen at php dot net) -+- Add support for php-trunk, new op code, new internals string format, etc. (Dmitry) -+- apc_debug are not compiler-valid NOPs for non-debug builds -+ -+- Fixed relative paths resolution when ./foo/a.php or ../foo/a.php (or similar path) -+ are used. 'foo/a.php' path behaviors remain unchanged -+- Fixed a possible memory corruption, when partial path cannot be resolved -+ by expand_filepath() -+- Fixed notices in apc.php (Tomasz Krawczyk) -+ -+- Fixed Bug #17978: standardize user keys to include NULs in identifier_len. Z_STRLEN_P() doesn't, so add to it. -+- Fixed bug #16966, apc produces tons of warnings "Unable to allocate memory for pool". -+ -+- Added --enable-apc-debug configuration argument to enable debugging (Kalle) -+- Added support for internal debugging on Windows (Kalle) -+- ZTS optimizations (Kalle) -+ -+ -+ -+ ---- /dev/null -+++ b/ext/apc/pgsql_s_lock.c +diff -Naur a/ext/apc/pgsql_s_lock.c b/ext/apc/pgsql_s_lock.c +--- a/ext/apc/pgsql_s_lock.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/pgsql_s_lock.c 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,391 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -15649,7 +15916,7 @@ + + */ + -+/* $Id: pgsql_s_lock.c 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: pgsql_s_lock.c 307048 2011-01-03 23:53:17Z kalle $ */ + +/*------------------------------------------------------------------------- + * @@ -16019,14 +16286,15 @@ +#endif /* HAVE_SPINLOCKS */ + +#endif /* APC_SPIN_LOCKS */ ---- /dev/null -+++ b/ext/apc/pgsql_s_lock.h +diff -Naur a/ext/apc/pgsql_s_lock.h b/ext/apc/pgsql_s_lock.h +--- a/ext/apc/pgsql_s_lock.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/pgsql_s_lock.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,928 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -16043,7 +16311,7 @@ + + */ + -+/* $Id: pgsql_s_lock.h 302175 2010-08-13 06:20:28Z kalle $ */ ++/* $Id: pgsql_s_lock.h 307048 2011-01-03 23:53:17Z kalle $ */ + +/*------------------------------------------------------------------------- + * @@ -16950,14 +17218,15 @@ +#endif + +#endif /* S_LOCK_H */ ---- /dev/null -+++ b/ext/apc/php_apc.c -@@ -0,0 +1,1812 @@ +diff -Naur a/ext/apc/php_apc.c b/ext/apc/php_apc.c +--- a/ext/apc/php_apc.c 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/php_apc.c 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,1716 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -16981,7 +17250,7 @@ + + */ + -+/* $Id: php_apc.c 303642 2010-09-21 15:42:01Z kalle $ */ ++/* $Id: php_apc.c 325875 2012-05-27 17:15:26Z felipe $ */ + +#include "apc_zend.h" +#include "apc_cache.h" @@ -17062,6 +17331,8 @@ + apc_globals->use_request_time = 1; + apc_globals->lazy_class_table = NULL; + apc_globals->lazy_function_table = NULL; ++ apc_globals->serializer_name = NULL; ++ apc_globals->serializer = NULL; +} + +static void php_apc_shutdown_globals(zend_apc_globals* apc_globals TSRMLS_DC) @@ -17087,35 +17358,35 @@ +static long apc_atol(const char *str, int str_len) +{ +#if PHP_MAJOR_VERSION >= 6 || PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3 -+ return zend_atol(str, str_len); ++ return zend_atol(str, str_len); +#else -+ /* Re-implement zend_atol() for 5.2.x */ -+ long retval; ++ /* Re-implement zend_atol() for 5.2.x */ ++ long retval; + -+ if (!str_len) { -+ str_len = strlen(str); -+ } ++ if (!str_len) { ++ str_len = strlen(str); ++ } + -+ retval = strtol(str, NULL, 0); ++ retval = strtol(str, NULL, 0); + -+ if (str_len > 0) { -+ switch (str[str_len - 1]) { -+ case 'g': -+ case 'G': -+ retval *= 1024; -+ /* break intentionally missing */ -+ case 'm': -+ case 'M': -+ retval *= 1024; -+ /* break intentionally missing */ -+ case 'k': -+ case 'K': -+ retval *= 1024; -+ break; -+ } -+ } ++ if (str_len > 0) { ++ switch (str[str_len - 1]) { ++ case 'g': ++ case 'G': ++ retval *= 1024; ++ /* break intentionally missing */ ++ case 'm': ++ case 'M': ++ retval *= 1024; ++ /* break intentionally missing */ ++ case 'k': ++ case 'K': ++ retval *= 1024; ++ break; ++ } ++ } + -+ return retval; ++ return retval; +#endif +} + @@ -17146,21 +17417,21 @@ + +static PHP_INI_MH(OnUpdateShmSize) /* {{{ */ +{ -+ long s = apc_atol(new_value, new_value_length); ++ long s = apc_atol(new_value, new_value_length); + -+ if(s <= 0) { -+ return FAILURE; -+ } ++ if(s <= 0) { ++ return FAILURE; ++ } + -+ if(s < 1048576L) { -+ /* if it's less than 1Mb, they are probably using the old syntax */ -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files"); -+ s = s * 1048576L; -+ } ++ if(s < 1048576L) { ++ /* if it's less than 1Mb, they are probably using the old syntax */ ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files"); ++ s = s * 1048576L; ++ } + -+ APCG(shm_size) = s; ++ APCG(shm_size) = s; + -+ return SUCCESS; ++ return SUCCESS; +} +/* }}} */ + @@ -17227,6 +17498,7 @@ +STD_PHP_INI_BOOLEAN("apc.use_request_time", "1", PHP_INI_ALL, OnUpdateBool, use_request_time, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.lazy_functions", "0", PHP_INI_SYSTEM, OnUpdateBool, lazy_functions, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.lazy_classes", "0", PHP_INI_SYSTEM, OnUpdateBool, lazy_classes, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.serializer", "default", PHP_INI_SYSTEM, OnUpdateStringUnempty, serializer_name, zend_apc_globals, apc_globals) +PHP_INI_END() + +/* }}} */ @@ -17234,6 +17506,10 @@ +/* {{{ PHP_MINFO_FUNCTION(apc) */ +static PHP_MINFO_FUNCTION(apc) +{ ++ apc_serializer_t *serializer = NULL; ++ smart_str names = {0,}; ++ int i; ++ + php_info_print_table_start(); + php_info_print_table_header(2, "APC Support", APCG(enabled) ? "enabled" : "disabled"); + php_info_print_table_row(2, "Version", PHP_APC_VERSION); @@ -17249,7 +17525,23 @@ + php_info_print_table_row(2, "MMAP Support", "Disabled"); +#endif + php_info_print_table_row(2, "Locking type", APC_LOCK_TYPE); -+ php_info_print_table_row(2, "Revision", "$Revision: 303642 $"); ++ ++ for( i = 0, serializer = apc_get_serializers(TSRMLS_C); ++ serializer->name != NULL; ++ serializer++, i++) { ++ if(i != 0) smart_str_appends(&names, ", "); ++ smart_str_appends(&names, serializer->name); ++ } ++ ++ if(names.c) { ++ smart_str_0(&names); ++ php_info_print_table_row(2, "Serialization Support", names.c); ++ smart_str_free(&names); ++ } else { ++ php_info_print_table_row(2, "Serialization Support", "broken"); ++ } ++ ++ php_info_print_table_row(2, "Revision", "$Revision: 325875 $"); + php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); + php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); @@ -17345,13 +17637,10 @@ +/* {{{ proto array apc_cache_info([string type [, bool limited]]) */ +PHP_FUNCTION(apc_cache_info) +{ -+ apc_cache_info_t* info; -+ apc_cache_link_t* p; -+ zval* list; ++ zval* info; + char *cache_type; + int ct_len; -+ zend_bool limited=0; -+ char md5str[33]; ++ zend_bool limited = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &cache_type, &ct_len, &limited) == FAILURE) { + return; @@ -17379,142 +17668,8 @@ + RETURN_FALSE; + } + -+ array_init(return_value); -+ add_assoc_long(return_value, "num_slots", info->num_slots); -+ add_assoc_long(return_value, "ttl", info->ttl); ++ RETURN_ZVAL(info, 0, 1); + -+ add_assoc_double(return_value, "num_hits", (double)info->num_hits); -+ add_assoc_double(return_value, "num_misses", (double)info->num_misses); -+ add_assoc_double(return_value, "num_inserts", (double)info->num_inserts); -+ add_assoc_double(return_value, "expunges", (double)info->expunges); -+ -+ add_assoc_long(return_value, "start_time", info->start_time); -+ add_assoc_double(return_value, "mem_size", (double)info->mem_size); -+ add_assoc_long(return_value, "num_entries", info->num_entries); -+#ifdef MULTIPART_EVENT_FORMDATA -+ add_assoc_long(return_value, "file_upload_progress", 1); -+#else -+ add_assoc_long(return_value, "file_upload_progress", 0); -+#endif -+#if APC_MMAP -+ add_assoc_stringl(return_value, "memory_type", "mmap", sizeof("mmap")-1, 1); -+#else -+ add_assoc_stringl(return_value, "memory_type", "IPC shared", sizeof("IPC shared")-1, 1); -+#endif -+#if APC_SEM_LOCKS -+ add_assoc_stringl(return_value, "locking_type", "IPC semaphore", sizeof("IPC semaphore")-1, 1); -+#elif APC_PTHREADMUTEX_LOCKS -+ add_assoc_stringl(return_value, "locking_type", "pthread mutex", sizeof("pthread mutex")-1, 1); -+#elif APC_SPIN_LOCKS -+ add_assoc_stringl(return_value, "locking_type", "spin", sizeof("spin")-1, 1); -+#else -+ add_assoc_stringl(return_value, "locking_type", "file", sizeof("file")-1, 1); -+#endif -+ if(limited) { -+ apc_cache_free_info(info TSRMLS_CC); -+ return; -+ } -+ -+ ALLOC_INIT_ZVAL(list); -+ array_init(list); -+ -+ for (p = info->list; p != NULL; p = p->next) { -+ zval* link; -+ -+ ALLOC_INIT_ZVAL(link); -+ array_init(link); -+ -+ if(p->type == APC_CACHE_ENTRY_FILE) { -+ add_assoc_string(link, "filename", p->data.file.filename, 1); -+#ifdef PHP_WIN32 -+ { -+ char buf[20]; -+ sprintf(buf, "%I64d", p->data.file.device); -+ add_assoc_string(link, "device", buf, 1); -+ -+ sprintf(buf, "%I64d", p->data.file.inode); -+ add_assoc_string(link, "inode", buf, 1); -+ } -+#else -+ add_assoc_long(link, "device", p->data.file.device); -+ add_assoc_long(link, "inode", p->data.file.inode); -+#endif -+ -+ -+ add_assoc_string(link, "type", "file", 1); -+ if(APCG(file_md5)) { -+ make_digest(md5str, p->data.file.md5); -+ add_assoc_string(link, "md5", md5str, 1); -+ } -+ } else if(p->type == APC_CACHE_ENTRY_USER) { -+ add_assoc_string(link, "info", p->data.user.info, 1); -+ add_assoc_long(link, "ttl", (long)p->data.user.ttl); -+ add_assoc_string(link, "type", "user", 1); -+ } -+ -+ add_assoc_double(link, "num_hits", (double)p->num_hits); -+ -+ add_assoc_long(link, "mtime", p->mtime); -+ add_assoc_long(link, "creation_time", p->creation_time); -+ add_assoc_long(link, "deletion_time", p->deletion_time); -+ add_assoc_long(link, "access_time", p->access_time); -+ add_assoc_long(link, "ref_count", p->ref_count); -+ add_assoc_long(link, "mem_size", p->mem_size); -+ -+ -+ add_next_index_zval(list, link); -+ } -+ add_assoc_zval(return_value, "cache_list", list); -+ -+ ALLOC_INIT_ZVAL(list); -+ array_init(list); -+ -+ for (p = info->deleted_list; p != NULL; p = p->next) { -+ zval* link; -+ -+ ALLOC_INIT_ZVAL(link); -+ array_init(link); -+ -+ if(p->type == APC_CACHE_ENTRY_FILE) { -+ add_assoc_string(link, "filename", p->data.file.filename, 1); -+#ifdef PHP_WIN32 -+ { -+ char buf[20]; -+ sprintf(buf, "%I64d", p->data.file.device); -+ add_assoc_string(link, "device", buf, 1); -+ -+ sprintf(buf, "%I64d", p->data.file.inode); -+ add_assoc_string(link, "inode", buf, 1); -+ } -+#else -+ add_assoc_long(link, "device", p->data.file.device); -+ add_assoc_long(link, "inode", p->data.file.inode); -+#endif -+ -+ add_assoc_string(link, "type", "file", 1); -+ if(APCG(file_md5)) { -+ make_digest(md5str, p->data.file.md5); -+ add_assoc_string(link, "md5", md5str, 1); -+ } -+ } else if(p->type == APC_CACHE_ENTRY_USER) { -+ add_assoc_string(link, "info", p->data.user.info, 1); -+ add_assoc_long(link, "ttl", (long)p->data.user.ttl); -+ add_assoc_string(link, "type", "user", 1); -+ } -+ -+ add_assoc_double(link, "num_hits", (double)p->num_hits); -+ -+ add_assoc_long(link, "mtime", p->mtime); -+ add_assoc_long(link, "creation_time", p->creation_time); -+ add_assoc_long(link, "deletion_time", p->deletion_time); -+ add_assoc_long(link, "access_time", p->access_time); -+ add_assoc_long(link, "ref_count", p->ref_count); -+ add_assoc_long(link, "mem_size", p->mem_size); -+ add_next_index_zval(list, link); -+ } -+ add_assoc_zval(return_value, "deleted_list", list); -+ -+ apc_cache_free_info(info TSRMLS_CC); +} +/* }}} */ + @@ -17614,6 +17769,11 @@ + return 0; + } + ++ if (!APCG(serializer) && APCG(serializer_name)) { ++ /* Avoid race conditions between MINIT of apc and serializer exts like igbinary */ ++ APCG(serializer) = apc_find_serializer(APCG(serializer_name) TSRMLS_CC); ++ } ++ + HANDLE_BLOCK_INTERRUPTIONS(); + APCG(current_cache) = apc_user_cache; + @@ -17641,6 +17801,11 @@ + + if(!APCG(enabled)) return 0; + ++ if (!APCG(serializer) && APCG(serializer_name)) { ++ /* Avoid race conditions between MINIT of apc and serializer exts like igbinary */ ++ APCG(serializer) = apc_find_serializer(APCG(serializer_name) TSRMLS_CC); ++ } ++ + HANDLE_BLOCK_INTERRUPTIONS(); + + APCG(current_cache) = apc_user_cache; @@ -17662,8 +17827,8 @@ + goto freepool; + } + -+ if (apc_cache_is_last_key(apc_user_cache, &key, 0, t TSRMLS_CC)) { -+ goto freepool; ++ if (apc_cache_is_last_key(apc_user_cache, &key, t TSRMLS_CC)) { ++ goto freepool; + } + + if (!(entry = apc_cache_make_user_entry(strkey, strkey_len, val, &ctxt, ttl TSRMLS_CC))) { @@ -17783,6 +17948,10 @@ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &strkey, &strkey_len, &(args.step), &success) == FAILURE) { + return; + } ++ ++ if (success) { ++ zval_dtor(success); ++ } + + if(_apc_update(strkey, strkey_len, inc_updater, &args TSRMLS_CC)) { + if(success) ZVAL_TRUE(success); @@ -17806,6 +17975,10 @@ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &strkey, &strkey_len, &(args.step), &success) == FAILURE) { + return; + } ++ ++ if (success) { ++ zval_dtor(success); ++ } + + args.step = args.step * -1; + @@ -18319,7 +18492,7 @@ + + orig_current_execute_data = EG(current_execute_data); + zend_try { -+ if (apc_compile_cache_entry(keys[i], &file_handle, ZEND_INCLUDE, t, &op_arrays[i], &cache_entries[i] TSRMLS_CC) != SUCCESS) { ++ if (apc_compile_cache_entry(&keys[i], &file_handle, ZEND_INCLUDE, t, &op_arrays[i], &cache_entries[i] TSRMLS_CC) != SUCCESS) { + op_arrays[i] = NULL; + cache_entries[i] = NULL; + add_assoc_long(return_value, Z_STRVAL_PP(hentry), -2); /* -2: input or cache insertion error */ @@ -18638,12 +18811,12 @@ + +PHP_APC_ARGINFO +ZEND_BEGIN_ARG_INFO(arginfo_apc_delete_file, 0) -+ ZEND_ARG_INFO(0, keys) ++ ZEND_ARG_INFO(0, keys) +ZEND_END_ARG_INFO() + +PHP_APC_ARGINFO +ZEND_BEGIN_ARG_INFO(arginfo_apc_delete, 0) -+ ZEND_ARG_INFO(0, keys) ++ ZEND_ARG_INFO(0, keys) +ZEND_END_ARG_INFO() + +PHP_APC_ARGINFO @@ -18708,7 +18881,7 @@ + +PHP_APC_ARGINFO +ZEND_BEGIN_ARG_INFO(arginfo_apc_exists, 0) -+ ZEND_ARG_INFO(0, keys) ++ ZEND_ARG_INFO(0, keys) +ZEND_END_ARG_INFO() +/* }}} */ + @@ -18765,14 +18938,15 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/php_apc.h +diff -Naur a/ext/apc/php_apc.h b/ext/apc/php_apc.h +--- a/ext/apc/php_apc.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/php_apc.h 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2010 The PHP Group | ++ | Copyright (c) 2006-2011 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -18797,7 +18971,7 @@ + + */ + -+/* $Id: php_apc.h 305846 2010-11-30 09:36:57Z gopalv $ */ ++/* $Id: php_apc.h 326713 2012-07-19 22:07:31Z rasmus $ */ + +#ifndef PHP_APC_H +#define PHP_APC_H @@ -18805,7 +18979,7 @@ +#include "apc_php.h" +#include "apc_globals.h" + -+#define PHP_APC_VERSION "3.1.6" ++#define PHP_APC_VERSION "3.1.11" + +extern zend_module_entry apc_module_entry; +#define apc_module_ptr &apc_module_entry @@ -18822,8 +18996,9 @@ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ ---- /dev/null -+++ b/ext/apc/TECHNOTES.txt +diff -Naur a/ext/apc/TECHNOTES.txt b/ext/apc/TECHNOTES.txt +--- a/ext/apc/TECHNOTES.txt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/TECHNOTES.txt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,361 @@ +APC Quick-Start Braindump + @@ -19012,7 +19187,7 @@ + }; + + Since this is at the start of the shared memory segment, these values are accessible -+ across all the yapache processes and hence access to them has to be locked. ++ across all the apache processes and hence access to them has to be locked. + + After the header we have an array of slots. The number of slots is user-defined + through the apc.num_slots ini hint. Each slot is described by: @@ -19186,8 +19361,9 @@ +If you made it to the end of this, you should have a pretty good idea of where things are in +the code. I skimmed over a lot of things, so plan on spending some time reading through the code. + ---- /dev/null -+++ b/ext/apc/tests/apc_001.phpt +diff -Naur a/ext/apc/tests/apc_001.phpt b/ext/apc/tests/apc_001.phpt +--- a/ext/apc/tests/apc_001.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_001.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,32 @@ +--TEST-- +APC: apc_store/fetch with strings @@ -19221,8 +19397,9 @@ +string(4) "nice" +string(11) "hello world" +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_002.phpt +diff -Naur a/ext/apc/tests/apc_002.phpt b/ext/apc/tests/apc_002.phpt +--- a/ext/apc/tests/apc_002.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_002.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,34 @@ +--TEST-- +APC: apc_store/fetch with objects @@ -19258,8 +19435,9 @@ + bool(true) +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_003b.phpt +diff -Naur a/ext/apc/tests/apc_003b.phpt b/ext/apc/tests/apc_003b.phpt +--- a/ext/apc/tests/apc_003b.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_003b.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,117 @@ +--TEST-- +APC: apc_store/fetch with objects (php 5.3) @@ -19378,8 +19556,9 @@ + bool(true) +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_003.phpt +diff -Naur a/ext/apc/tests/apc_003.phpt b/ext/apc/tests/apc_003.phpt +--- a/ext/apc/tests/apc_003.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_003.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,117 @@ +--TEST-- +APC: apc_store/fetch with objects (php pre-5.3) @@ -19498,8 +19677,9 @@ + bool(true) +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_004.phpt +diff -Naur a/ext/apc/tests/apc_004.phpt b/ext/apc/tests/apc_004.phpt +--- a/ext/apc/tests/apc_004.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_004.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,38 @@ +--TEST-- +APC: apc_store/fetch with bools @@ -19539,8 +19719,9 @@ +bool(false) +bool(false) +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_005.phpt +diff -Naur a/ext/apc/tests/apc_005.phpt b/ext/apc/tests/apc_005.phpt +--- a/ext/apc/tests/apc_005.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_005.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,50 @@ +--TEST-- +APC: apc_store/fetch with arrays of objects @@ -19592,9 +19773,10 @@ + } +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/apc_006.phpt -@@ -0,0 +1,72 @@ +diff -Naur a/ext/apc/tests/apc_006.phpt b/ext/apc/tests/apc_006.phpt +--- a/ext/apc/tests/apc_006.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_006.phpt 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,73 @@ +--TEST-- +APC: apc_store/fetch reference test +--SKIPIF-- @@ -19603,6 +19785,7 @@ +apc.enabled=1 +apc.enable_cli=1 +apc.file_update_protection=0 ++apc.serializer=default +report_memleaks=0 +--FILE-- + ---- /dev/null -+++ b/ext/apc/tests/apc_bin_002.phpt +diff -Naur a/ext/apc/tests/apc_bin_002.phpt b/ext/apc/tests/apc_bin_002.phpt +--- a/ext/apc/tests/apc_bin_002.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/apc_bin_002.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,53 @@ +--TEST-- +APC: bindump file cache part 1 @@ -20269,8 +20465,9 @@ +inherited class constant: Success + +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_001.phpt +diff -Naur a/ext/apc/tests/iterator_001.phpt b/ext/apc/tests/iterator_001.phpt +--- a/ext/apc/tests/iterator_001.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_001.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,110 @@ +--TEST-- +APC: APCIterator general @@ -20382,8 +20579,9 @@ + string(4) "key9" +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_002.phpt +diff -Naur a/ext/apc/tests/iterator_002.phpt b/ext/apc/tests/iterator_002.phpt +--- a/ext/apc/tests/iterator_002.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_002.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,36 @@ +--TEST-- +APC: APCIterator regex @@ -20421,8 +20619,9 @@ + string(5) "key40" +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_003.phpt +diff -Naur a/ext/apc/tests/iterator_003.phpt b/ext/apc/tests/iterator_003.phpt +--- a/ext/apc/tests/iterator_003.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_003.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,110 @@ +--TEST-- +APC: APCIterator chunk size @@ -20534,8 +20733,9 @@ + string(4) "key9" +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_004.phpt +diff -Naur a/ext/apc/tests/iterator_004.phpt b/ext/apc/tests/iterator_004.phpt +--- a/ext/apc/tests/iterator_004.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_004.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,36 @@ +--TEST-- +APC: APCIterator regex & chunk size & list @@ -20573,8 +20773,9 @@ + string(5) "key40" +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_005.phpt +diff -Naur a/ext/apc/tests/iterator_005.phpt b/ext/apc/tests/iterator_005.phpt +--- a/ext/apc/tests/iterator_005.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_005.phpt 2012-07-20 00:10:35.000000000 +0200 @@ -0,0 +1,112 @@ +--TEST-- +APC: APCIterator delete @@ -20688,9 +20889,10 @@ + string(4) "key9" +} +===DONE=== ---- /dev/null -+++ b/ext/apc/tests/iterator_006.phpt -@@ -0,0 +1,1535 @@ +diff -Naur a/ext/apc/tests/iterator_006.phpt b/ext/apc/tests/iterator_006.phpt +--- a/ext/apc/tests/iterator_006.phpt 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/tests/iterator_006.phpt 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,1536 @@ +--TEST-- +APC: APCIterator formats +--SKIPIF-- @@ -20699,6 +20901,7 @@ +apc.enabled=1 +apc.enable_cli=1 +apc.file_update_protection=0 ++apc.user_entries_hint=4096 +--FILE-- + ---- /dev/null -+++ b/ext/apc/TODO -@@ -0,0 +1,32 @@ +diff -Naur a/ext/apc/TODO b/ext/apc/TODO +--- a/ext/apc/TODO 1970-01-01 01:00:00.000000000 +0100 ++++ b/ext/apc/TODO 2012-07-20 00:10:35.000000000 +0200 +@@ -0,0 +1,35 @@ +Known Bugs + +1. Gallery2 doesn't work with PHP5+APC. There is something wrong @@ -22323,11 +22530,14 @@ + +1. The following configurations (build arguments) have not been implemented yet + -+ (*) --enable-apc-mmap Memory mapping support -+ (*) --enable-apc-sem Semaphore locking support (FCNTL replacement) -+ (*) --enable-apc-phreadmutex Thread mutexes, while implemented we should probably rename the internals to thread ++ (*) --enable-apc-mmap Memory mapping support ++ (*) --enable-apc-sem Semaphore locking support (FCNTL replacement) ++ (*) --enable-apc-phreadmutex Thread mutexes, while implemented we should probably rename the internals to thread ++ (*) --enable-apc-pthreadrwlocks Thread mutexes, read/write locking + +2. Non-blocking locks is not supported either + +3. Update fileinfo to support stat info in a more portable way (see PECL #17903) -\ No newline at end of file ++ ++4. Check whether the signal handling needs to be enabled, and if it makes sense on Windows +\ Kein Zeilenumbruch am Dateiende.