copy internal functions/classes into sandbox, they're needed by compiler
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@344 c26eb9a1-5813-0410-bd6c-c2e55f420ca73.0
parent
7081e28e4d
commit
bf38b8775c
15
utils.c
15
utils.c
|
@ -1,5 +1,7 @@
|
|||
|
||||
#include "xcache.h"
|
||||
#include "stack.h"
|
||||
#include "xcache_globals.h"
|
||||
#include "utils.h"
|
||||
#ifdef ZEND_ENGINE_2_1
|
||||
#include "zend_vm.h"
|
||||
|
@ -530,6 +532,9 @@ static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */
|
|||
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
HashTable *h;
|
||||
zend_function tmp_func;
|
||||
xc_cest_t tmp_cest;
|
||||
|
||||
if (sandbox) {
|
||||
memset(sandbox, 0, sizeof(sandbox[0]));
|
||||
}
|
||||
|
@ -566,8 +571,14 @@ 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));
|
||||
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));
|
||||
TG(internal_class_tail) = TG(class_table).pListTail;
|
||||
|
||||
#ifdef ZEND_ENGINE_2_1
|
||||
/* shallow copy, don't destruct */
|
||||
h = OG(auto_globals);
|
||||
|
@ -612,7 +623,7 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
|
|||
}
|
||||
#endif
|
||||
|
||||
b = TG(function_table).pListHead;
|
||||
b = TG(internal_function_tail) ? TG(internal_function_tail)->pListNext : TG(function_table).pListHead;
|
||||
/* install function */
|
||||
while (b != NULL) {
|
||||
zend_function *func = (zend_function*) b->pData;
|
||||
|
@ -621,7 +632,7 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
|
|||
b = b->pListNext;
|
||||
}
|
||||
|
||||
b = TG(class_table).pListHead;
|
||||
b = TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead;
|
||||
/* install class */
|
||||
while (b != NULL) {
|
||||
xc_install_class(sandbox->filename, (xc_cest_t*) b->pData, -1,
|
||||
|
|
2
utils.h
2
utils.h
|
@ -70,6 +70,8 @@ typedef struct {
|
|||
HashTable tmp_function_table;
|
||||
HashTable tmp_class_table;
|
||||
HashTable tmp_auto_globals;
|
||||
Bucket *tmp_internal_function_tail;
|
||||
Bucket *tmp_internal_class_tail;
|
||||
} xc_sandbox_t;
|
||||
|
||||
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC);
|
||||
|
|
19
xcache.c
19
xcache.c
|
@ -1024,14 +1024,16 @@ static zend_op_array *xc_compile_php(xc_entry_data_php_t *php, zend_file_handle
|
|||
/* {{{ shallow copy, pointers only */ {
|
||||
Bucket *b;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
#define COPY_H(vartype, var, cnt, name, datatype) do { \
|
||||
for (i = 0; b; i ++, b = b->pListNext) { \
|
||||
vartype *data = &php->var[i]; \
|
||||
for (i = 0, j = 0; b; i ++, b = b->pListNext) { \
|
||||
vartype *data = &php->var[j]; \
|
||||
\
|
||||
if (i < old_##cnt) { \
|
||||
continue; \
|
||||
} \
|
||||
j ++; \
|
||||
\
|
||||
assert(i < old_##cnt + php->cnt); \
|
||||
assert(b->pData); \
|
||||
|
@ -1602,6 +1604,16 @@ static void xc_request_init(TSRMLS_D) /* {{{ */
|
|||
{
|
||||
int i;
|
||||
|
||||
if (XG(internal_function_table).nTableSize == 0) {
|
||||
zend_function tmp_func;
|
||||
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_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));
|
||||
}
|
||||
if (xc_php_hcache.size && !XG(php_holds)) {
|
||||
XG(php_holds) = calloc(xc_php_hcache.size, sizeof(xc_stack_t));
|
||||
for (i = 0; i < xc_php_hcache.size; i ++) {
|
||||
|
@ -1675,6 +1687,9 @@ void xc_shutdown_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
|
|||
free(xcache_globals->var_holds);
|
||||
xcache_globals->var_holds = NULL;
|
||||
}
|
||||
|
||||
zend_hash_destroy(&xcache_globals->internal_function_table);
|
||||
zend_hash_destroy(&xcache_globals->internal_class_table);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ ZEND_BEGIN_MODULE_GLOBALS(xcache)
|
|||
xc_stack_t *var_holds;
|
||||
time_t request_time;
|
||||
long var_ttl;
|
||||
|
||||
HashTable internal_function_table;
|
||||
HashTable internal_class_table;
|
||||
ZEND_END_MODULE_GLOBALS(xcache)
|
||||
|
||||
ZEND_EXTERN_MODULE_GLOBALS(xcache)
|
||||
|
|
Loading…
Reference in New Issue