Browse Source

fix #36, wrong inheriting static class variables

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@196 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.2
Xuefer 15 years ago
parent
commit
01bd668358
  1. 11
      processor/hashtable.m4
  2. 47
      processor/head.m4
  3. 6
      processor/processor.m4
  4. 2
      xcache.c

11
processor/hashtable.m4

@ -1,4 +1,4 @@
dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname])
dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname] [, 4:check_function])
define(`DEF_HASH_TABLE_FUNC', `
DEF_STRUCT_P_FUNC(`HashTable', `$1', `
pushdefFUNC_NAME(`$2', `$3')
@ -93,6 +93,15 @@ define(`DEF_HASH_TABLE_FUNC', `
DISABLECHECK(`
for (b = src->pListHead; b != NULL; b = b->pListNext) {
ifelse(`$4', `', `', `
pushdef(`BUCKET', `b')
if ($4 == ZEND_HASH_APPLY_REMOVE) {
IFCOPY(`dst->nNumOfElements --;')
continue;
}
popdef(`BUCKET')
')
IFCALCCOPY(`bucketsize = BUCKET_SIZE(b);')
ALLOC(pnew, char, bucketsize, , Bucket)
IFCOPY(`memcpy(pnew, b, bucketsize);')

47
processor/head.m4

@ -246,6 +246,53 @@ dnl FIXME: handle common.function_name here
}
}
/* }}} */
static int xc_hash_static_member_check(xc_processor_t *processor, Bucket *b TSRMLS_DC) /* {{{ */
{
zend_class_entry *src = processor->active_class_entry_src;
if (src->parent) {
zval **srczv;
if (zend_hash_quick_find(CE_STATIC_MEMBERS(src), b->arKey, b->nKeyLength, b->h, (void **) &srczv) == SUCCESS) {
zval **zv = (zval **) b->pData;
if (*srczv == *zv) {
return ZEND_HASH_APPLY_REMOVE;
}
}
}
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
/* fix static members on restore */
static void inherit_static_prop(zval **p) /* {{{ */
{
(*p)->refcount++;
(*p)->is_ref = 1;
}
/* }}} */
static void xc_fix_static_members(xc_processor_t *processor, zend_class_entry *dst TSRMLS_DC) /* {{{ */
{
zend_class_entry *parent_ce = dst->parent;
if (parent_ce->type != dst->type) {
/* User class extends internal class */
zend_update_class_constants(parent_ce TSRMLS_CC);
zend_hash_merge(&dst->default_static_members, CE_STATIC_MEMBERS(parent_ce), (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
}
else {
zend_hash_merge(&dst->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
}
/*
HashPosition pos;
HashTable *pmembers = CE_STATIC_MEMBERS(dst->parent);
zval **zv;
for (zend_hash_internal_pointer_reset_ex(pmembers, &pos);
zend_hash_get_current_data_ex(pmembers, (void **) &zv, &pos) == SUCCESS;
zend_hash_move_forward_ex(pmembers, &pos)) {
if (zend_hash_quick_find(parent->static_members, p->arKey, p->nKeyLength, p->h, &pprop.ptr) == SUCCESS) {
}
}
*/
}
/* }}} */
#endif
/* {{{ call op_array ctor handler */
extern zend_bool xc_have_op_array_ctor;

6
processor/processor.m4

@ -64,6 +64,7 @@ DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `
')
dnl }}}
DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr')
DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_static_member_check', `zval_ptr', , `xc_hash_static_member_check(processor, BUCKET TSRMLS_CC)')
#ifdef HAVE_XCACHE_CONSTANT
DEF_HASH_TABLE_FUNC(`HashTable_zend_constant', `zend_constant')
#endif
@ -296,11 +297,12 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{
#ifdef ZEND_ENGINE_2
STRUCT(HashTable, properties_info, HashTable_zend_property_info)
# ifdef ZEND_ENGINE_2_1
STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
STRUCT(HashTable, default_static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
IFCOPY(`dst->static_members = &dst->default_static_members;')
IFRESTORE(`if (dst->parent) xc_fix_static_members(processor, dst TSRMLS_CC);')
DONE(static_members)
# else
STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
STRUCT_P(HashTable, static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
# endif
STRUCT(HashTable, constants_table, HashTable_zval_ptr)

2
xcache.c

@ -2461,7 +2461,7 @@ ZEND_GET_MODULE(xcache)
/* }}} */
static startup_func_t xc_last_ext_startup;
static zend_llist_element *xc_llist_element;
static xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
{
return p1 == p2;
}

Loading…
Cancel
Save