1
0
Fork 0

copy function/class table correctly by using add_ref

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@345 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 2007-02-04 08:15:00 +00:00
parent bf38b8775c
commit 69120fa668
3 changed files with 15 additions and 4 deletions

14
utils.c
View File

@ -529,6 +529,16 @@ static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */
}
/* }}} */
#endif
void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce))
{
#ifdef ZEND_ENGINE_2
(*ce)->refcount++;
#else
(*ce->refcount)++;
#endif
}
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
{
HashTable *h;
@ -571,12 +581,12 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /
#endif
h = OG(function_table);
zend_hash_init_ex(&TG(function_table), 128, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
zend_hash_copy(&TG(function_table), &XG(internal_function_table), NULL, (void *) &tmp_func, sizeof(tmp_func));
zend_hash_copy(&TG(function_table), &XG(internal_function_table), (copy_ctor_func_t) function_add_ref, (void *) &tmp_func, sizeof(tmp_func));
TG(internal_class_tail) = TG(function_table).pListTail;
h = OG(class_table);
zend_hash_init_ex(&TG(class_table), 16, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
zend_hash_copy(&TG(class_table), &XG(internal_class_table), NULL, (void *) &tmp_cest, sizeof(tmp_cest));
zend_hash_copy(&TG(class_table), &XG(internal_class_table), (copy_ctor_func_t) xc_zend_class_add_ref, (void *) &tmp_cest, sizeof(tmp_cest));
TG(internal_class_tail) = TG(class_table).pListTail;
#ifdef ZEND_ENGINE_2_1

View File

@ -74,5 +74,6 @@ typedef struct {
Bucket *tmp_internal_class_tail;
} xc_sandbox_t;
void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce));
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC);
void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC);

View File

@ -1609,10 +1609,10 @@ static void xc_request_init(TSRMLS_D) /* {{{ */
xc_cest_t tmp_cest;
zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
zend_hash_copy(&XG(internal_function_table), CG(function_table), (copy_ctor_func_t) function_add_ref, &tmp_func, sizeof(tmp_func));
zend_hash_init_ex(&XG(internal_class_table), 10, NULL, NULL, 1, 0);
zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
zend_hash_copy(&XG(internal_class_table), CG(class_table), (copy_ctor_func_t) xc_zend_class_add_ref, &tmp_cest, sizeof(tmp_cest));
}
if (xc_php_hcache.size && !XG(php_holds)) {
XG(php_holds) = calloc(xc_php_hcache.size, sizeof(xc_stack_t));