cvs: pecl /apc apc_compile.c apc_globals.h apc_php.h apc_zend.c php_apc.c

From: Date: Wed, 25 Oct 2006 18:46:34 +0000
Subject: cvs: pecl /apc apc_compile.c apc_globals.h apc_php.h apc_zend.c php_apc.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-6544@lists.php.net to get a copy of this message
gopalv Wed Oct 25 18:46:34 2006 UTC Modified files: /pecl/apc apc_compile.c apc_globals.h apc_php.h apc_zend.c php_apc.c Log: Fix bug #8814 by allocating a slot in z_op_array->reserved[] with zend_get_resource_handle on a dummy zend_extension struct. http://cvs.php.net/viewvc.cgi/pecl/apc/apc_compile.c?r1=3.62&r2=3.63&diff_format=u Index: pecl/apc/apc_compile.c diff -u pecl/apc/apc_compile.c:3.62 pecl/apc/apc_compile.c:3.63 --- pecl/apc/apc_compile.c:3.62 Tue Oct 17 06:11:25 2006 +++ pecl/apc/apc_compile.c Wed Oct 25 18:46:34 2006 @@ -28,7 +28,7 @@ */ -/* $Id: apc_compile.c,v 3.62 2006/10/17 06:11:25 shire Exp $ */ +/* $Id: apc_compile.c,v 3.63 2006/10/25 18:46:34 gopalv Exp $ */ #include "apc_compile.h" #include "apc_globals.h" @@ -1186,9 +1186,13 @@ } #ifdef ZEND_ENGINE_2 - flags = (apc_opflags_t*) & (dst->reserved); - memset(flags, 0, sizeof(apc_opflags_t)); - /* assert(sizeof(apc_opflags_t) < sizeof(dst->reserved)); */ + if(APCG(reserved_offset) != -1) { + /* Insanity alert: the void* pointer is cast into an apc_opflags_t + * struct. apc_zend_init() checks to ensure that it fits in a void* */ + flags = (apc_opflags_t*) & (dst->reserved[APCG(reserved_offset)]); + memset(flags, 0, sizeof(apc_opflags_t)); + /* assert(sizeof(apc_opflags_t) < sizeof(dst->reserved)); */ + } #endif for (i = 0; i < src->last; i++) { @@ -1201,7 +1205,9 @@ case ZEND_JMPNZ: case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: - flags->has_jumps = 1; + if(flags != NULL) { + flags->has_jumps = 1; + } break; #ifdef ZEND_ENGINE_2 /* auto_globals_jit was not in php-4.3.* */ @@ -1209,7 +1215,7 @@ case ZEND_FETCH_W: case ZEND_FETCH_IS: case ZEND_FETCH_FUNC_ARG: - if(PG(auto_globals_jit)) + if(PG(auto_globals_jit) && flags != NULL) { /* The fetch is only required if auto_globals_jit=1 */ if(zo->op2.u.EA.type == ZEND_FETCH_GLOBAL && @@ -1226,7 +1232,9 @@ case ZEND_RECV_INIT: if(zo->op2.op_type == IS_CONST && zo->op2.u.constant.type == IS_CONSTANT_ARRAY) { - flags->deep_copy = 1; + if(flags != NULL) { + flags->deep_copy = 1; + } } break; default: @@ -1234,7 +1242,9 @@ zo->op1.u.constant.type == IS_CONSTANT_ARRAY) || (zo->op2.op_type == IS_CONST && zo->op2.u.constant.type == IS_CONSTANT_ARRAY)) { - flags->deep_copy = 1; + if(flags != NULL) { + flags->deep_copy = 1; + } } break; } @@ -1249,7 +1259,7 @@ } #ifdef ZEND_ENGINE_2 - if(flags->has_jumps) { + if(flags == NULL || flags->has_jumps) { apc_fixup_op_array_jumps(dst,src); } #endif @@ -1910,11 +1920,12 @@ int i; int needcopy = 0; #ifdef ZEND_ENGINE_2 - apc_opflags_t * flags = (apc_opflags_t*)&(src->reserved); + apc_opflags_t * flags = APCG(reserved_offset) != -1 ? + (apc_opflags_t*) & (src->reserved[APCG(reserved_offset)]) : NULL; #endif #ifdef ZEND_ENGINE_2 - needcopy = flags->deep_copy; + needcopy = flags ? flags->deep_copy : 1; #else needcopy = 1; #endif @@ -1962,7 +1973,7 @@ case ZEND_FETCH_W: case ZEND_FETCH_IS: case ZEND_FETCH_FUNC_ARG: - if(PG(auto_globals_jit) && flags->use_globals) + if(PG(auto_globals_jit) && (flags == NULL || flags->use_globals)) { /* The fetch is only required if auto_globals_jit=1 */ if(zo->op2.u.EA.type == ZEND_FETCH_GLOBAL && @@ -1989,9 +2000,6 @@ /* {{{ apc_copy_op_array_for_execution */ zend_op_array* apc_copy_op_array_for_execution(zend_op_array* dst, zend_op_array* src TSRMLS_DC) { -#ifdef ZEND_ENGINE_2 - apc_opflags_t * flags = (apc_opflags_t*)&(src->reserved); -#endif if(dst == NULL) { dst = (zend_op_array*) emalloc(sizeof(src[0])); } http://cvs.php.net/viewvc.cgi/pecl/apc/apc_globals.h?r1=3.51&r2=3.52&diff_format=u Index: pecl/apc/apc_globals.h diff -u pecl/apc/apc_globals.h:3.51 pecl/apc/apc_globals.h:3.52 --- pecl/apc/apc_globals.h:3.51 Tue Oct 17 06:11:25 2006 +++ pecl/apc/apc_globals.h Wed Oct 25 18:46:34 2006 @@ -29,7 +29,7 @@ */ -/* $Id: apc_globals.h,v 3.51 2006/10/17 06:11:25 shire Exp $ */ +/* $Id: apc_globals.h,v 3.52 2006/10/25 18:46:34 gopalv Exp $ */ #ifndef APC_GLOBALS_H #define APC_GLOBALS_H @@ -74,7 +74,10 @@ #ifdef MULTIPART_EVENT_FORMDATA zend_bool rfc1867; /* Flag to enable rfc1867 handler */ #endif - HashTable *copied_zvals; /* my_copy recursion detection list */ + HashTable *copied_zvals; /* my_copy recursion detection list */ +#ifdef ZEND_ENGINE_2 + int reserved_offset; /* offset for apc info in op_array->reserved[] */ +#endif ZEND_END_MODULE_GLOBALS(apc) /* (the following declaration is defined in php_apc.c) */ http://cvs.php.net/viewvc.cgi/pecl/apc/apc_php.h?r1=3.8&r2=3.9&diff_format=u Index: pecl/apc/apc_php.h diff -u pecl/apc/apc_php.h:3.8 pecl/apc/apc_php.h:3.9 --- pecl/apc/apc_php.h:3.8 Thu Aug 17 05:43:40 2006 +++ pecl/apc/apc_php.h Wed Oct 25 18:46:34 2006 @@ -29,7 +29,7 @@ */ -/* $Id: apc_php.h,v 3.8 2006/08/17 05:43:40 rasmus Exp $ */ +/* $Id: apc_php.h,v 3.9 2006/10/25 18:46:34 gopalv Exp $ */ #ifndef APC_PHP_H #define APC_PHP_H @@ -45,6 +45,7 @@ #include "zend_API.h" #include "zend_compile.h" #include "zend_hash.h" +#include "zend_extensions.h" #if ZEND_MODULE_API_NO > 20050922 #define ZEND_ENGINE_2_2 http://cvs.php.net/viewvc.cgi/pecl/apc/apc_zend.c?r1=3.10&r2=3.11&diff_format=u Index: pecl/apc/apc_zend.c diff -u pecl/apc/apc_zend.c:3.10 pecl/apc/apc_zend.c:3.11 --- pecl/apc/apc_zend.c:3.10 Mon Sep 18 21:29:22 2006 +++ pecl/apc/apc_zend.c Wed Oct 25 18:46:34 2006 @@ -25,7 +25,7 @@ */ -/* $Id: apc_zend.c,v 3.10 2006/09/18 21:29:22 rasmus Exp $ */ +/* $Id: apc_zend.c,v 3.11 2006/10/25 18:46:34 gopalv Exp $ */ #include "apc_zend.h" #include "apc_globals.h" @@ -204,6 +204,13 @@ void apc_zend_init(TSRMLS_D) { + zend_extension dummy_ext; +#ifdef ZEND_ENGINE_2 + APCG(reserved_offset) = zend_get_resource_handle(&dummy_ext); + assert(APCG(reserved_offset) == dummy_ext.resource_number); + assert(APCG(reserved_offset) != -1); + assert(sizeof(apc_opflags_t) <= sizeof(void*)); +#endif if (!APCG(include_once)) { /* If we're not overriding the INCLUDE_OR_EVAL handler, then just skip this malarkey */ return; http://cvs.php.net/viewvc.cgi/pecl/apc/php_apc.c?r1=3.116&r2=3.117&diff_format=u Index: pecl/apc/php_apc.c diff -u pecl/apc/php_apc.c:3.116 pecl/apc/php_apc.c:3.117 --- pecl/apc/php_apc.c:3.116 Tue Oct 17 06:11:25 2006 +++ pecl/apc/php_apc.c Wed Oct 25 18:46:34 2006 @@ -26,7 +26,7 @@ */ -/* $Id: php_apc.c,v 3.116 2006/10/17 06:11:25 shire Exp $ */ +/* $Id: php_apc.c,v 3.117 2006/10/25 18:46:34 gopalv Exp $ */ #include "apc_zend.h" #include "apc_cache.h" @@ -82,6 +82,9 @@ apc_globals->rfc1867 = 0; #endif apc_globals->copied_zvals = NULL; +#ifdef ZEND_ENGINE_2 + apc_globals->reserved_offset = -1; +#endif } static void php_apc_shutdown_globals(zend_apc_globals* apc_globals TSRMLS_DC) @@ -167,7 +170,7 @@ #else php_info_print_table_row(2, "Locking type", "File Locks"); #endif - php_info_print_table_row(2, "Revision", "$Revision: 3.116 $"); + php_info_print_table_row(2, "Revision", "$Revision: 3.117 $"); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); php_info_print_table_end(); DISPLAY_INI_ENTRIES();

« previous php.pecl.cvs (#6544) next »