Browse Source

merged r363,r366,r376,r381,r382,r383,r384,r385,r386,r387 from trunk

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.3@602 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.3
Xuefer 13 years ago
parent
commit
90eef477e3
  1. 5
      ChangeLog
  2. 3
      NEWS
  3. 2
      admin/xcache.php
  4. 65
      xc_malloc.c
  5. 31
      xcache.c

5
ChangeLog

@ -1,3 +1,8 @@
1.3.0 2009-??-??
== ChangeLog ==
* could not show module info in admin page when XCache is the last module
* wrong http auth realm
1.2.2 2007-12-29
== ChangeLog ==
* added module dependency

3
NEWS

@ -1,3 +1,6 @@
1.3.0 2009-??-??
========
1.2.2 2007-12-29
========
* live with wrong system time: allow caching files with mtime in further

2
admin/xcache.php

@ -206,7 +206,7 @@ default:
ob_start();
phpinfo(INFO_MODULES);
$moduleinfo = ob_get_clean();
if (preg_match('!XCache</a></h2>(.*?)<h2><a name="module_!is', $moduleinfo, $m)) {
if (preg_match('!XCache</a></h2>(.*?)<h2>!is', $moduleinfo, $m)) {
$moduleinfo = $m[1];
}
else {

65
xc_malloc.c

@ -19,32 +19,62 @@ struct _xc_malloc_mem_t {
xc_memsize_t avail; /* total free */
};
/* {{{ _xc_malloc_shm_t */
struct _xc_malloc_shm_t {
xc_shm_handlers_t *handlers;
xc_shmsize_t size;
xc_shmsize_t memoffset;
#ifdef HAVE_XCACHE_TEST
HashTable blocks;
#endif
};
/* }}} */
#define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
static void *xc_add_to_blocks(xc_mem_t *mem, void *p, size_t size) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
if (p) {
zend_hash_add(&mem->shm->blocks, (void *) &p, sizeof(p), (void *) &size, sizeof(size), NULL);
}
#endif
return p;
}
/* }}} */
static void xc_del_from_blocks(xc_mem_t *mem, void *p) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
zend_hash_del(&mem->shm->blocks, (void *) &p, sizeof(p));
#endif
}
/* }}} */
static XC_MEM_MALLOC(xc_malloc_malloc) /* {{{ */
{
return malloc(size);
return xc_add_to_blocks(mem, malloc(size), size);
}
/* }}} */
static XC_MEM_FREE(xc_malloc_free) /* {{{ return block size freed */
{
xc_del_from_blocks(mem, (void *) p);
free((void *) p);
return 0;
}
/* }}} */
static XC_MEM_CALLOC(xc_malloc_calloc) /* {{{ */
{
return calloc(memb, size);
return xc_add_to_blocks(mem, calloc(memb, size), size);
}
/* }}} */
static XC_MEM_REALLOC(xc_malloc_realloc) /* {{{ */
{
return realloc((void *) p, size);
return xc_add_to_blocks(mem, realloc((void *) p, size), size);
}
/* }}} */
static XC_MEM_STRNDUP(xc_malloc_strndup) /* {{{ */
{
char *p = malloc(len);
char *p = xc_add_to_blocks(mem, malloc(len), len);
if (!p) {
return NULL;
}
@ -110,14 +140,6 @@ static XC_MEM_DESTROY(xc_mem_malloc_destroy) /* {{{ */
}
/* }}} */
/* {{{ _xc_malloc_shm_t */
struct _xc_malloc_shm_t {
xc_shm_handlers_t *handlers;
xc_shmsize_t size;
xc_shmsize_t memoffset;
};
/* }}} */
static XC_SHM_CAN_READONLY(xc_malloc_can_readonly) /* {{{ */
{
return 0;
@ -125,6 +147,19 @@ static XC_SHM_CAN_READONLY(xc_malloc_can_readonly) /* {{{ */
/* }}} */
static XC_SHM_IS_READWRITE(xc_malloc_is_readwrite) /* {{{ */
{
HashPosition pos;
size_t *psize;
char **ptr;
zend_hash_internal_pointer_reset_ex(&shm->blocks, &pos);
while (zend_hash_get_current_data_ex(&shm->blocks, (void **) &psize, &pos) == SUCCESS) {
zend_hash_get_current_key_ex(&shm->blocks, (void *) &ptr, NULL, NULL, 0, &pos);
if ((char *) p >= *ptr && (char *) p < *ptr + *psize) {
return 1;
}
zend_hash_move_forward_ex(&shm->blocks, &pos);
}
return 0;
}
/* }}} */
@ -146,6 +181,9 @@ static XC_SHM_TO_READONLY(xc_malloc_to_readonly) /* {{{ */
static XC_SHM_DESTROY(xc_malloc_destroy) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
zend_hash_destroy(&shm->blocks);
#endif
free(shm);
return;
}
@ -156,6 +194,9 @@ static XC_SHM_INIT(xc_malloc_init) /* {{{ */
CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM");
shm->size = size;
#ifdef HAVE_XCACHE_TEST
zend_hash_init(&shm->blocks, 64, NULL, NULL, 1);
#endif
return shm;
err:
return NULL;

31
xcache.c

@ -391,7 +391,13 @@ static void xc_fillinfo_dmz(int cachetype, xc_cache_t *cache, zval *return_value
#endif
xc_mem_t *mem = cache->mem;
const xc_mem_handlers_t *handlers = mem->handlers;
zend_ulong interval = (cachetype == XC_TYPE_PHP) ? xc_php_gc_interval : xc_var_gc_interval;
zend_ulong interval;
if (cachetype == XC_TYPE_PHP) {
interval = xc_php_ttl ? xc_php_gc_interval : 0;
}
else {
interval = xc_var_gc_interval;
}
add_assoc_long_ex(return_value, ZEND_STRS("slots"), cache->hentry->size);
add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cache->compiling);
@ -404,7 +410,8 @@ static void xc_fillinfo_dmz(int cachetype, xc_cache_t *cache, zval *return_value
add_assoc_long_ex(return_value, ZEND_STRS("cached"), cache->entries_count);
add_assoc_long_ex(return_value, ZEND_STRS("deleted"), cache->deletes_count);
if (interval) {
add_assoc_long_ex(return_value, ZEND_STRS("gc"), (cache->last_gc_expires + interval) - XG(request_time));
time_t gc = (cache->last_gc_expires + interval) - XG(request_time);
add_assoc_long_ex(return_value, ZEND_STRS("gc"), gc > 0 ? gc : 0);
}
else {
add_assoc_null_ex(return_value, ZEND_STRS("gc"));
@ -1623,7 +1630,7 @@ static int xcache_admin_auth_check(TSRMLS_D) /* {{{ */
}
}
#define STR "WWW-authenticate: basic realm='XCache Administration'"
#define STR "WWW-authenticate: Basic Realm=\"XCache Administration\""
sapi_add_header_ex(STR, sizeof(STR) - 1, 1, 1 TSRMLS_CC);
#undef STR
#define STR "HTTP/1.0 401 Unauthorized"
@ -2452,14 +2459,14 @@ static PHP_MINFO_FUNCTION(xcache)
/* {{{ extension startup */
static void xc_zend_extension_register(zend_extension *new_extension, DL_HANDLE handle)
{
zend_extension extension;
zend_extension extension;
extension = *new_extension;
extension.handle = handle;
extension = *new_extension;
extension.handle = handle;
zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);
zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);
zend_llist_prepend_element(&zend_extensions, &extension);
zend_llist_prepend_element(&zend_extensions, &extension);
TRACE("%s", "registered");
}
@ -2512,11 +2519,11 @@ static void xc_llist_unlink(zend_llist *l, zend_llist_element *element)
static int xc_zend_extension_startup(zend_extension *extension)
{
if (extension->startup) {
if (extension->startup(extension) != SUCCESS) {
if (extension->startup) {
if (extension->startup(extension) != SUCCESS) {
return FAILURE;
}
}
}
}
return SUCCESS;
}
/* }}} */

Loading…
Cancel
Save