1
0
Fork 0

cacher: hide more detail

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1132 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 11 years ago
parent 22bd66f2d3
commit 6b2ab887aa

@ -16,20 +16,6 @@ typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
struct _xc_lock_t;
struct _xc_shm_t;
/* {{{ xc_cache_t: only cache info, not in shm */
typedef struct {
int cacheid;
xc_hash_t *hcache; /* hash to cacheid */
struct _xc_lock_t *lck;
struct _xc_shm_t *shm; /* which shm contains us */
struct _xc_mem_t *mem; /* which mem contains us */
xc_hash_t *hentry; /* hash settings to entry */
xc_hash_t *hphp; /* hash settings to php */
xc_cached_t *cached;
} xc_cache_t;
/* }}} */
/* {{{ xc_op_array_info_detail_t */
typedef struct {
zend_uint index;

@ -93,6 +93,19 @@ struct _xc_cached_t { /* {{{ stored in shm */
zend_ulong hits_by_second[5];
};
/* }}} */
typedef struct { /* {{{ xc_cache_t: only cache info, not in shm */
int cacheid;
xc_hash_t *hcache; /* hash to cacheid */
struct _xc_lock_t *lck;
struct _xc_shm_t *shm; /* which shm contains us */
struct _xc_mem_t *mem; /* which mem contains us */
xc_hash_t *hentry; /* hash settings to entry */
xc_hash_t *hphp; /* hash settings to php */
xc_cached_t *cached;
} xc_cache_t;
/* }}} */
/* {{{ globals */
static char *xc_shm_scheme = NULL;
@ -149,7 +162,7 @@ static xc_entry_data_php_t *xc_php_store_unlocked(xc_cache_t *cache, xc_entry_da
php->hits = 0;
php->refcount = 0;
stored_php = xc_processor_store_xc_entry_data_php_t(cache, php TSRMLS_CC);
stored_php = xc_processor_store_xc_entry_data_php_t(cache->shm, cache->mem, php TSRMLS_CC);
if (stored_php) {
xc_php_add_unlocked(cache->cached, stored_php);
return stored_php;
@ -296,8 +309,8 @@ static xc_entry_t *xc_entry_store_unlocked(xc_entry_type_t type, xc_cache_t *cac
entry->ctime = XG(request_time);
entry->atime = XG(request_time);
stored_entry = type == XC_TYPE_PHP
? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache, (xc_entry_php_t *) entry TSRMLS_CC)
: (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache, (xc_entry_var_t *) entry TSRMLS_CC);
? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache->shm, cache->mem, (xc_entry_php_t *) entry TSRMLS_CC)
: (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache->shm, cache->mem, (xc_entry_var_t *) entry TSRMLS_CC);
if (stored_entry) {
xc_entry_add_unlocked(cache->cached, entryslotid, stored_entry);
++cache->cached->updates;
@ -3284,7 +3297,6 @@ static int xc_config_long(zend_ulong *p, char *name, char *default_value) /* {{{
/* }}} */
static PHP_MINIT_FUNCTION(xcache_cacher) /* {{{ */
{
char *env;
zend_extension *ext;
zend_llist_position lpos;

@ -93,7 +93,8 @@ struct _xc_processor_t {
const xc_entry_php_t *entry_php_dst;
const xc_entry_data_php_t *php_src;
const xc_entry_data_php_t *php_dst;
const xc_cache_t *cache;
xc_shm_t *shm;
xc_mem_t *mem;
const zend_class_entry *cache_ce;
zend_uint cache_class_index;
@ -393,14 +394,15 @@ static int xc_check_names(const char *file, int line, const char *functionName,
/* }}} */
dnl ================ export API
define(`DEFINE_STORE_API', `
/* export: $1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC); :export {{{ */
$1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC) {
/* export: $1 *xc_processor_store_$1(xc_shm_t *shm, xc_mem_t *mem, $1 *src TSRMLS_DC); :export {{{ */
$1 *xc_processor_store_$1(xc_shm_t *shm, xc_mem_t *mem, $1 *src TSRMLS_DC) {
$1 *dst;
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
processor.reference = 1;
processor.cache = cache;
processor.shm = shm;
processor.mem = mem;
IFAUTOCHECK(`xc_stack_init(&processor.allocsizes);')
@ -438,7 +440,7 @@ $1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC) {
}
/* mem :) */
processor.p = (char *) processor.cache->mem->handlers->malloc(processor.cache->mem, processor.size);
processor.p = (char *) processor.mem->handlers->malloc(processor.mem, processor.size);
if (processor.p == NULL) {
dst = NULL;
goto err_alloc;

@ -125,11 +125,11 @@ dnl }}}
dnl {{{ FIXPOINTER
define(`FIXPOINTER', `FIXPOINTER_EX(`$1', `dst->$2')')
define(`FIXPOINTER_EX', `IFSTORE(`
$2 = ($1 *) processor->cache->shm->handlers->to_readonly(processor->cache->shm, (char *)$2);
$2 = ($1 *) processor->shm->handlers->to_readonly(processor->shm, (char *)$2);
')')
define(`UNFIXPOINTER', `UNFIXPOINTER_EX(`$1', `dst->$2')')
define(`UNFIXPOINTER_EX', `IFSTORE(`
$2 = ($1 *) processor->cache->shm->handlers->to_readwrite(processor->cache->shm, (char *)$2);
$2 = ($1 *) processor->shm->handlers->to_readwrite(processor->shm, (char *)$2);
')')
dnl }}}
dnl {{{ COPY

Loading…
Cancel
Save