1
0
Fork 0

merged [405] [407] from trunk: fixed #92, full ZendOptimizer compatibility

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.2@408 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2007-05-31 04:20:14 +00:00
parent 390ac1f0a5
commit 3047dcc9a2
6 changed files with 50 additions and 16 deletions

View File

@ -4,6 +4,7 @@
== ChangeLog ==
* #86: remove/edit variable in admin page
* fixed #92: Zend Optimizer compatibility issue
* fixed #77: hits/misses was not updated
* fixed #59: pass by reference for internal function was broken
* fixed #56: xcache_set segfaults when xcache.var_size=0

8
NEWS
View File

@ -1,10 +1,10 @@
1.2.1 2007-?-?
* ini settings changed
* bug fixes
========
* full Zend Optimizer compatibility
* ini settings changed
* other bug fixes
1.2.0 2006-12-10
NEWS
========
* full 5.2 support
* minor admin/coverage-viewer page improves

16
utils.c
View File

@ -629,7 +629,7 @@ static void xc_early_binding_cb(zend_op *opline, int oplineno, void *data TSRMLS
xc_do_early_binding(CG(active_op_array), OG(class_table), oplineno TSRMLS_CC);
}
/* }}} */
static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */
{
int i;
Bucket *b;
@ -673,15 +673,17 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
}
#endif
xc_undo_pass_two(CG(active_op_array) TSRMLS_CC);
xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC);
xc_redo_pass_two(CG(active_op_array) TSRMLS_CC);
if (install != XC_InstallNoBinding) {
xc_undo_pass_two(CG(active_op_array) TSRMLS_CC);
xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC);
xc_redo_pass_two(CG(active_op_array) TSRMLS_CC);
}
i = 1;
zend_hash_add(&OG(included_files), sandbox->filename, strlen(sandbox->filename) + 1, (void *)&i, sizeof(int), NULL);
}
/* }}} */
void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC) /* {{{ */
void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */
{
/* restore first first install function/class */
#ifdef HAVE_XCACHE_CONSTANT
@ -694,11 +696,11 @@ void xc_sandbox_free(xc_sandbox_t *sandbox, int install TSRMLS_DC) /* {{{ */
CG(auto_globals) = OG(auto_globals);
#endif
if (install) {
if (install != XC_NoInstall) {
CG(in_compilation) = 1;
CG(compiled_filename) = sandbox->filename;
CG(zend_lineno) = 0;
xc_sandbox_install(sandbox TSRMLS_CC);
xc_sandbox_install(sandbox, install TSRMLS_CC);
CG(in_compilation) = 0;
CG(compiled_filename) = NULL;

View File

@ -56,6 +56,12 @@ typedef struct {
Bucket *tmp_internal_class_tail;
} xc_sandbox_t;
typedef enum _xc_install_action_t {
XC_NoInstall,
XC_Install,
XC_InstallNoBinding
} xc_install_action_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);
void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC);

View File

@ -97,6 +97,7 @@ static xc_cache_t **xc_php_caches = NULL;
static xc_cache_t **xc_var_caches = NULL;
static zend_bool xc_initized = 0;
static zend_compile_file_t *origin_compile_file = NULL;
static zend_compile_file_t *old_compile_file = NULL;
static zend_llist_element *xc_llist_zend_extension = NULL;
@ -837,6 +838,12 @@ static void xc_cache_early_binding_class_cb(zend_op *opline, int oplineno, void
}
}
/* }}} */
static zend_op_array *xc_check_initial_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
{
XG(initial_compile_file_called) = 1;
return origin_compile_file(h, type TSRMLS_CC);
}
/* }}} */
static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
{
xc_sandbox_t sandbox;
@ -940,6 +947,7 @@ static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /
old_funcinfo_cnt = zend_hash_num_elements(CG(function_table));
old_constinfo_cnt = zend_hash_num_elements(EG(zend_constants));
XG(initial_compile_file_called) = 0;
zend_try {
op_array = old_compile_file(h, type TSRMLS_CC);
} zend_catch {
@ -954,6 +962,11 @@ static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /
goto err_oparray;
}
if (!XG(initial_compile_file_called)) {
xc_sandbox_free(&sandbox, XC_InstallNoBinding TSRMLS_CC);
return op_array;
}
filename = h->opened_path ? h->opened_path : h->filename;
/* none-inode enabled entry hash/compare on name
* do not update to its name to real pathname
@ -1124,15 +1137,15 @@ err_bailout:
if (xc_test && stored_xce) {
/* free it, no install. restore now */
xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
}
else if (!op_array) {
/* failed to compile free it, no install */
xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
}
else {
CG(active_op_array) = op_array;
xc_sandbox_free(&sandbox, 1 TSRMLS_CC);
xc_sandbox_free(&sandbox, XC_Install TSRMLS_CC);
}
ENTER_LOCK(cache) {
@ -1379,6 +1392,11 @@ static void xc_destroy() /* {{{ */
old_compile_file = NULL;
}
if (origin_compile_file) {
zend_compile_file = origin_compile_file;
origin_compile_file = NULL;
}
if (xc_php_caches) {
shm = xc_cache_destroy(xc_php_caches, &xc_php_hcache);
xc_php_caches = NULL;
@ -2745,7 +2763,7 @@ zend_module_entry xcache_module_entry = {
ZEND_GET_MODULE(xcache)
#endif
/* }}} */
static startup_func_t xc_last_ext_startup = NULL;
static startup_func_t xc_last_ext_startup;
static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
{
/* restore */
@ -2766,6 +2784,12 @@ static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
ZEND_DLEXPORT int xcache_zend_startup(zend_extension *extension) /* {{{ */
{
xc_zend_extension_gotup = 1;
if (!origin_compile_file) {
origin_compile_file = zend_compile_file;
zend_compile_file = xc_check_initial_compile_file;
}
if (zend_llist_count(&zend_extensions) > 1) {
zend_llist_position lpos;
zend_extension *ext;

View File

@ -1,5 +1,6 @@
ZEND_BEGIN_MODULE_GLOBALS(xcache)
zend_bool initial_compile_file_called; /* true is origin_compile_file is called */
zend_bool cacher; /* true if enabled */
zend_bool stat;
#ifdef HAVE_XCACHE_OPTIMIZER