summaryrefslogtreecommitdiff
path: root/processor
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2014-11-12 18:55:52 +0000
committerXuefer <xuefer@gmail.com>2014-11-12 18:55:52 +0000
commitf843d679ae78a623f2050f971bd0dc3496ce217d (patch)
treee54ea74e001a9338f12645e2bd8f9049b2c7f19d /processor
parentb6d67b60d6f67e6ea3784add7ff56d8bf53c06e2 (diff)
downloadxcache-f843d679ae78a623f2050f971bd0dc3496ce217d.tar.gz
xcache-f843d679ae78a623f2050f971bd0dc3496ce217d.zip
fix some xcache_get leak by refcount
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1576 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'processor')
-rw-r--r--processor/foot.m46
-rw-r--r--processor/processor.m412
2 files changed, 10 insertions, 8 deletions
diff --git a/processor/foot.m4 b/processor/foot.m4
index 0bfe239..27eef0c 100644
--- a/processor/foot.m4
+++ b/processor/foot.m4
@@ -124,9 +124,6 @@ EXPORTED_FUNCTION(`void xc_processor_restore_var(zval *dst, zval **dst_ptr, cons
if (processor.handle_reference) {
zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
- if (dst_ptr) {
- zval_ptr_dtor(dst_ptr);
- }
}
processor.index_to_ce = index_to_ce;
@@ -144,11 +141,14 @@ EXPORTED_FUNCTION(`void xc_processor_restore_var(zval *dst, zval **dst_ptr, cons
}
}
#endif
+ zval_ptr_dtor(&dst);
if (dst_ptr) {
xc_restore_zval_ptr(&processor, dst_ptr, &src->value TSRMLS_CC);
+ Z_ADDREF(**dst_ptr);
}
else {
xc_restore_zval(&processor, dst, src->value TSRMLS_CC);
+ Z_ADDREF(*dst);
}
if (processor.handle_reference) {
zend_hash_destroy(&processor.zvalptrs);
diff --git a/processor/processor.m4 b/processor/processor.m4
index b202bda..8977fa7 100644
--- a/processor/processor.m4
+++ b/processor/processor.m4
@@ -306,7 +306,6 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
RELOCATE_EX(zval, pzv)
')
if (zend_hash_add(&processor->zvalptrs, (char *) &SRC()[0], sizeof(SRC()[0]), (void *) &pzv, sizeof(pzv), NULL) == SUCCESS) { /* first add, go on */
- IFSTORE(`Z_SET_REFCOUNT(**DST(), 1);')
dnl IFSTORE(`fprintf(stderr, "mark[%p] = %p\n", (void *) SRC()[0], (void *) pzv);')
}
else {
@@ -319,6 +318,8 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{
')
IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", (void *) SRC()[0]);')
STRUCT_P_EX(zval, DST()[0], SRC()[0], `[0]', `', ` ')
+ dnl don't set refcount in zval processor
+ IFSTORE(`Z_SET_REFCOUNT(**DST(), 1);')
RELOCATE_EX(zval, DST()[0])
} while (0);
')
@@ -1418,21 +1419,23 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
STRUCT_P_EX(zval_ptr, DST(`value'), SRC(`value'), `value', `', `&')
+ DONE(value)
#if 0
IFSTORE(`
{
HashTable *ht;
zval **zv;
- assert(Z_TYPE_P(SRC(`value')) == IS_ARRAY);
- ht = Z_ARRVAL_P(SRC(`value'));
+ assert(Z_TYPE_P(DST(`value')) == IS_ARRAY);
+ ht = Z_ARRVAL_P(DST(`value'));
assert(ht->nNumOfElements == 1);
fprintf(stderr, "key %s\n", ht->pListHead->arKey);
zv = (zval **) ht->pListHead->pData;
- fprintf(stderr, "%d\n", Z_TYPE_PP(zv));
assert(Z_TYPE_PP(zv) == IS_ARRAY);
assert(Z_ARRVAL_PP(zv) == ht);
+ fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(*DST(`value')));
+ fprintf(stderr, "refcount=%d\n", Z_REFCOUNT(**zv));
}
')
#endif
@@ -1482,7 +1485,6 @@ DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
')
PROCESS(zend_bool, have_references)
- DONE(value)
')
dnl }}}
dnl ====================================================