Browse Source

PHP_5_3: deep copy arg_info which is modified by executor

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@498 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 14 years ago
parent
commit
6c747e7378
  1. 3
      processor/processor.m4
  2. 33
      xcache.c
  3. 1
      xcache.h
  4. 2
      xcache_globals.h

3
processor/processor.m4

@ -503,12 +503,15 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{
dnl shadow copy must NOT meet:
dnl readonly_protection=on
dnl main op_array && have early binding
zend_uint ii;
if (!processor->readonly_protection && !(src == processor->php_src->op_array && processor->php_src->have_early_binding)) {
/* really fast shallow copy */
memcpy(dst, src, sizeof(src[0]));
dst->refcount[0] = 1000;
/* deep */
STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info)
xc_gc_add_op_array(dst TSRMLS_CC);
define(`SKIPASSERT_ONCE')
}
else

33
xcache.c

@ -1476,6 +1476,36 @@ int xc_is_shm(const void *p) /* {{{ */
}
/* }}} */
/* {{{ xc_gc_op_array_t */
typedef struct {
zend_uint num_args;
zend_arg_info *arg_info;
} xc_gc_op_array_t;
/* }}} */
void xc_gc_add_op_array(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
xc_gc_op_array_t gc_op_array;
gc_op_array.num_args = op_array->num_args;
gc_op_array.arg_info = op_array->arg_info;
zend_hash_next_index_insert(&XG(gc_op_arrays), (void *) &gc_op_array, sizeof(gc_op_array), NULL);
}
/* }}} */
static void xc_gc_op_array(void *pDest) /* {{{ */
{
xc_gc_op_array_t *op_array = (xc_gc_op_array_t *) pDest;
zend_uint i;
if (op_array->arg_info) {
for (i = 0; i < op_array->num_args; i++) {
efree((char*)op_array->arg_info[i].name);
if (op_array->arg_info[i].class_name) {
efree((char*)op_array->arg_info[i].class_name);
}
}
efree(op_array->arg_info);
}
}
/* }}} */
/* module helper function */
static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */
{
@ -1710,6 +1740,8 @@ static void xc_request_init(TSRMLS_D) /* {{{ */
}
}
zend_hash_init(&XG(gc_op_arrays), 32, NULL, xc_gc_op_array, 0);
#if PHP_API_VERSION <= 20041225
XG(request_time) = time(NULL);
#else
@ -1724,6 +1756,7 @@ static void xc_request_init(TSRMLS_D) /* {{{ */
static void xc_request_shutdown(TSRMLS_D) /* {{{ */
{
xc_entry_unholds(TSRMLS_C);
zend_hash_destroy(&XG(gc_op_arrays));
xc_gc_expires_php(TSRMLS_C);
xc_gc_expires_var(TSRMLS_C);
xc_gc_deletes(TSRMLS_C);

1
xcache.h

@ -360,5 +360,6 @@ extern zend_module_entry xcache_module_entry;
int xc_is_rw(const void *p);
int xc_is_ro(const void *p);
int xc_is_shm(const void *p);
void xc_gc_add_op_array(zend_op_array *op_array TSRMLS_DC);
#endif /* __XCACHE_H */

2
xcache_globals.h

@ -17,6 +17,8 @@ ZEND_BEGIN_MODULE_GLOBALS(xcache)
time_t request_time;
long var_ttl;
HashTable gc_op_arrays;
HashTable internal_function_table;
HashTable internal_class_table;
zend_bool internal_table_copied;

Loading…
Cancel
Save