cvs: ZendEngine2(PHP_5_1) / zend.c zend_API.c zend_API.h zend_builtin_functions.c zend_compile.c zend_globals.h zend_object_handlers.c zend_opcode.c
php-src NEWS
| From: | Dmitry Stogov | Date: | Thu, 01 Dec 2005 11:47:36 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend.c zend_API.c zend_API.h zend_builtin_functions.c zend_compile.c zend_globals.h zend_object_handlers.c zend_opcode.c php-src NEWS |
||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4410@lists.php.net to get a copy of this message | ||
dmitry Thu Dec 1 06:47:36 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src NEWS
/ZendEngine2 zend.c zend_API.c zend_API.h zend_builtin_functions.c
zend_compile.c zend_globals.h zend_object_handlers.c
zend_opcode.c
Log:
Fixed bug #34729 (Crash in ZTS mode under Apache)
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.261&r2=1.2027.2.262&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.261 php-src/NEWS:1.2027.2.262 --- php-src/NEWS:1.2027.2.261 Wed Nov 30 18:51:23 2005 +++ php-src/NEWS Thu Dec 1 06:47:14 2005 @@ -19,6 +19,7 @@ connecting to 5.x server. (Andrey) - Fixed bug #35496 (Crash in mcrypt_generic()/mdecrypt_generic() without proper init). (Ilia) +- Fixed bug #34729 (Crash in ZTS mode under Apache). (Dmitry, Zeev) - Fixed bug #35470 (Assigning global using variable name from array doesn't function). (Dmitry) - Fixed bug #35456 (+ 1 [time unit] format did not work). (Ilia) http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.308.2.5&r2=1.308.2.6&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.308.2.5 ZendEngine2/zend.c:1.308.2.6 --- ZendEngine2/zend.c:1.308.2.5 Wed Nov 30 05:29:44 2005 +++ ZendEngine2/zend.c Thu Dec 1 06:47:29 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.308.2.5 2005/11/30 10:29:44 dmitry Exp $ */ +/* $Id: zend.c,v 1.308.2.6 2005/12/01 11:47:29 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -453,6 +453,13 @@ compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0); zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL, NULL, sizeof(zend_auto_global) /* empty element */); + + compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table); + if (compiler_globals->last_static_member) { + compiler_globals->static_members = (HashTable**)calloc(compiler_globals->last_static_member, sizeof(HashTable*)); + } else { + compiler_globals->static_members = NULL; + } } @@ -470,6 +477,10 @@ zend_hash_destroy(compiler_globals->auto_globals); free(compiler_globals->auto_globals); } + if (compiler_globals->static_members) { + free(compiler_globals->static_members); + } + compiler_globals->last_static_member = 0; } http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.296.2.12&r2=1.296.2.13&ty=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.296.2.12 ZendEngine2/zend_API.c:1.296.2.13 --- ZendEngine2/zend_API.c:1.296.2.12 Wed Nov 23 13:51:44 2005 +++ ZendEngine2/zend_API.c Thu Dec 1 06:47:29 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.296.2.12 2005/11/23 18:51:44 tony2001 Exp $ */ +/* $Id: zend_API.c,v 1.296.2.13 2005/12/01 11:47:29 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -755,22 +755,26 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) { - if (!class_type->constants_updated || !class_type->static_members) { + if (!class_type->constants_updated || !CE_STATIC_MEMBERS(class_type)) { zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); zend_class_entry *old_scope = *scope; *scope = class_type; zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); - if (!class_type->static_members) { + if (!CE_STATIC_MEMBERS(class_type)) { HashPosition pos; zval **p; if (class_type->parent) { zend_update_class_constants(class_type->parent TSRMLS_CC); } +#if ZTS + ALLOC_HASHTABLE(CG(static_members)[(long)(class_type->static_members)]); +#else ALLOC_HASHTABLE(class_type->static_members); - zend_hash_init(class_type->static_members, 0, NULL, ZVAL_PTR_DTOR, 0); +#endif + zend_hash_init(CE_STATIC_MEMBERS(class_type), 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos); while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) { @@ -784,10 +788,10 @@ class_type->parent && zend_hash_find(&class_type->parent->default_static_members, str_index, str_length, (void**)&q) == SUCCESS && *p == *q && - zend_hash_find(class_type->parent->static_members, str_index, str_length, (void**)&q) == SUCCESS) { + zend_hash_find(CE_STATIC_MEMBERS(class_type->parent), str_index, str_length, (void**)&q) == SUCCESS) { (*q)->refcount++; (*q)->is_ref = 1; - zend_hash_add(class_type->static_members, str_index, str_length, (void**)q, sizeof(zval*), NULL); + zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)q, sizeof(zval*), NULL); } else { zval *q; @@ -795,12 +799,12 @@ *q = **p; INIT_PZVAL(q); zval_copy_ctor(q); - zend_hash_add(class_type->static_members, str_index, str_length, (void**)&q, sizeof(zval*), NULL); + zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)&q, sizeof(zval*), NULL); } zend_hash_move_forward_ex(&class_type->default_static_members, &pos); } } - zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); + zend_hash_apply_with_argument(CE_STATIC_MEMBERS(class_type), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); *scope = old_scope; class_type->constants_updated = 1; http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.207.2.3&r2=1.207.2.4&ty=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.207.2.3 ZendEngine2/zend_API.h:1.207.2.4 --- ZendEngine2/zend_API.h:1.207.2.3 Fri Oct 28 10:46:29 2005 +++ ZendEngine2/zend_API.h Thu Dec 1 06:47:30 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.207.2.3 2005/10/28 14:46:29 dmitry Exp $ */ +/* $Id: zend_API.h,v 1.207.2.4 2005/12/01 11:47:30 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -146,6 +146,12 @@ #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) +#ifdef ZTS +# define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members:CG(static_members)[(long)(ce)->static_members]) +#else +# define CE_STATIC_MEMBERS(ce) ((ce)->static_members) +#endif + int zend_next_free_module(void); BEGIN_EXTERN_C() http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.6&r2=1.277.2.7&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.6 ZendEngine2/zend_builtin_functions.c:1.277.2.7 --- ZendEngine2/zend_builtin_functions.c:1.277.2.6 Thu Nov 24 00:07:27 2005 +++ ZendEngine2/zend_builtin_functions.c Thu Dec 1 06:47:30 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.277.2.6 2005/11/24 05:07:27 sebastian Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.277.2.7 2005/12/01 11:47:30 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" @@ -738,7 +738,7 @@ array_init(return_value); add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC); zend_update_class_constants(*pce TSRMLS_CC); - add_class_vars(*pce, (*pce)->static_members, return_value TSRMLS_CC); + add_class_vars(*pce, CE_STATIC_MEMBERS(*pce), return_value TSRMLS_CC); } } /* }}} */ http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.647.2.18&r2=1.647.2.19&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.18 ZendEngine2/zend_compile.c:1.647.2.19 --- ZendEngine2/zend_compile.c:1.647.2.18 Sun Nov 27 01:39:27 2005 +++ ZendEngine2/zend_compile.c Thu Dec 1 06:47:31 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.18 2005/11/27 06:39:27 iliaa Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.19 2005/12/01 11:47:31 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -2090,7 +2090,9 @@ if (parent_ce->type != ce->type) { /* User class extends internal class */ - ht = parent_ce->static_members; + TSRMLS_FETCH(); + + ht = CE_STATIC_MEMBERS(parent_ce); } else { ht = &parent_ce->default_static_members; } @@ -2196,7 +2198,7 @@ if (parent_ce->type != ce->type) { /* User class extends internal class */ zend_update_class_constants(parent_ce TSRMLS_CC); - zend_hash_merge(&ce->default_static_members, parent_ce->static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); + zend_hash_merge(&ce->default_static_members, CE_STATIC_MEMBERS(parent_ce), (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); } else { zend_hash_merge(&ce->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); } @@ -4026,7 +4028,23 @@ zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0); zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); - ce->static_members = (ce->type == ZEND_INTERNAL_CLASS) ? NULL : &ce->default_static_members; + if (ce->type == ZEND_INTERNAL_CLASS) { +#ifdef ZTS + int n = zend_hash_num_elements(CG(class_table)); + + if (CG(static_members) && n >= CG(last_static_member)) { + /* Support for run-time declaration: dl() */ + CG(last_static_member) = n+1; + CG(static_members) = realloc(CG(static_members), (n+1)*sizeof(HashTable*)); + CG(static_members)[n] = NULL; + } + ce->static_members = (HashTable*)n; +#else + ce->static_members = NULL; +#endif + } else { + ce->static_members = &ce->default_static_members; + } if (nullify_handlers) { ce->constructor = NULL; http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.141.2.1&r2=1.141.2.2&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.141.2.1 ZendEngine2/zend_globals.h:1.141.2.2 --- ZendEngine2/zend_globals.h:1.141.2.1 Tue Nov 15 08:29:28 2005 +++ ZendEngine2/zend_globals.h Thu Dec 1 06:47:33 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.141.2.1 2005/11/15 13:29:28 dmitry Exp $ */ +/* $Id: zend_globals.h,v 1.141.2.2 2005/12/01 11:47:33 dmitry Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -144,6 +144,11 @@ zend_encoding_converter encoding_converter; zend_encoding_oddlen encoding_oddlen; #endif /* ZEND_MULTIBYTE */ + +#ifdef ZTS + HashTable **static_members; + int last_static_member; +#endif }; http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.135.2.4&r2=1.135.2.5&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.135.2.4 ZendEngine2/zend_object_handlers.c:1.135.2.5 --- ZendEngine2/zend_object_handlers.c:1.135.2.4 Wed Nov 16 06:52:27 2005 +++ ZendEngine2/zend_object_handlers.c Thu Dec 1 06:47:33 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.135.2.4 2005/11/16 11:52:27 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.135.2.5 2005/12/01 11:47:33 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -857,7 +857,7 @@ zend_update_class_constants(tmp_ce TSRMLS_CC); - zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); + zend_hash_quick_find(CE_STATIC_MEMBERS(tmp_ce), property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); if (!retval) { if (silent) { http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.110.2.1&r2=1.110.2.2&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.110.2.1 ZendEngine2/zend_opcode.c:1.110.2.2 --- ZendEngine2/zend_opcode.c:1.110.2.1 Thu Sep 1 06:05:32 2005 +++ ZendEngine2/zend_opcode.c Thu Dec 1 06:47:34 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.110.2.1 2005/09/01 10:05:32 dmitry Exp $ */ +/* $Id: zend_opcode.c,v 1.110.2.2 2005/12/01 11:47:34 dmitry Exp $ */ #include <stdio.h> @@ -138,18 +138,20 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) { - if ((*pce)->static_members) { - if ((*pce)->static_members != &(*pce)->default_static_members) { - zend_hash_destroy((*pce)->static_members); - FREE_HASHTABLE((*pce)->static_members); - } - (*pce)->static_members = NULL; - } if ((*pce)->type == ZEND_USER_CLASS) { /* Clean all parts that can contain run-time data */ /* Note that only run-time accessed data need to be cleaned up, pre-defined data can not contain objects and thus are not probelmatic */ zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC); + (*pce)->static_members = NULL; + } else if (CE_STATIC_MEMBERS(*pce)) { + zend_hash_destroy(CE_STATIC_MEMBERS(*pce)); + FREE_HASHTABLE(CE_STATIC_MEMBERS(*pce)); +#ifdef ZTS + CG(static_members)[(long)((*pce)->static_members)] = NULL; +#else + (*pce)->static_members = NULL; +#endif } return 0; }
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.261&r2=1.2027.2.262&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.261 php-src/NEWS:1.2027.2.262 --- php-src/NEWS:1.2027.2.261 Wed Nov 30 18:51:23 2005 +++ php-src/NEWS Thu Dec 1 06:47:14 2005 @@ -19,6 +19,7 @@ connecting to 5.x server. (Andrey) - Fixed bug #35496 (Crash in mcrypt_generic()/mdecrypt_generic() without proper init). (Ilia) +- Fixed bug #34729 (Crash in ZTS mode under Apache). (Dmitry, Zeev) - Fixed bug #35470 (Assigning global using variable name from array doesn't function). (Dmitry) - Fixed bug #35456 (+ 1 [time unit] format did not work). (Ilia) http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.308.2.5&r2=1.308.2.6&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.308.2.5 ZendEngine2/zend.c:1.308.2.6 --- ZendEngine2/zend.c:1.308.2.5 Wed Nov 30 05:29:44 2005 +++ ZendEngine2/zend.c Thu Dec 1 06:47:29 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.308.2.5 2005/11/30 10:29:44 dmitry Exp $ */ +/* $Id: zend.c,v 1.308.2.6 2005/12/01 11:47:29 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -453,6 +453,13 @@ compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, 0); zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL, NULL, sizeof(zend_auto_global) /* empty element */); + + compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table); + if (compiler_globals->last_static_member) { + compiler_globals->static_members = (HashTable**)calloc(compiler_globals->last_static_member, sizeof(HashTable*)); + } else { + compiler_globals->static_members = NULL; + } } @@ -470,6 +477,10 @@ zend_hash_destroy(compiler_globals->auto_globals); free(compiler_globals->auto_globals); } + if (compiler_globals->static_members) { + free(compiler_globals->static_members); + } + compiler_globals->last_static_member = 0; } http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.296.2.12&r2=1.296.2.13&ty=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.296.2.12 ZendEngine2/zend_API.c:1.296.2.13 --- ZendEngine2/zend_API.c:1.296.2.12 Wed Nov 23 13:51:44 2005 +++ ZendEngine2/zend_API.c Thu Dec 1 06:47:29 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.296.2.12 2005/11/23 18:51:44 tony2001 Exp $ */ +/* $Id: zend_API.c,v 1.296.2.13 2005/12/01 11:47:29 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -755,22 +755,26 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) { - if (!class_type->constants_updated || !class_type->static_members) { + if (!class_type->constants_updated || !CE_STATIC_MEMBERS(class_type)) { zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); zend_class_entry *old_scope = *scope; *scope = class_type; zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); - if (!class_type->static_members) { + if (!CE_STATIC_MEMBERS(class_type)) { HashPosition pos; zval **p; if (class_type->parent) { zend_update_class_constants(class_type->parent TSRMLS_CC); } +#if ZTS + ALLOC_HASHTABLE(CG(static_members)[(long)(class_type->static_members)]); +#else ALLOC_HASHTABLE(class_type->static_members); - zend_hash_init(class_type->static_members, 0, NULL, ZVAL_PTR_DTOR, 0); +#endif + zend_hash_init(CE_STATIC_MEMBERS(class_type), 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos); while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) { @@ -784,10 +788,10 @@ class_type->parent && zend_hash_find(&class_type->parent->default_static_members, str_index, str_length, (void**)&q) == SUCCESS && *p == *q && - zend_hash_find(class_type->parent->static_members, str_index, str_length, (void**)&q) == SUCCESS) { + zend_hash_find(CE_STATIC_MEMBERS(class_type->parent), str_index, str_length, (void**)&q) == SUCCESS) { (*q)->refcount++; (*q)->is_ref = 1; - zend_hash_add(class_type->static_members, str_index, str_length, (void**)q, sizeof(zval*), NULL); + zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)q, sizeof(zval*), NULL); } else { zval *q; @@ -795,12 +799,12 @@ *q = **p; INIT_PZVAL(q); zval_copy_ctor(q); - zend_hash_add(class_type->static_members, str_index, str_length, (void**)&q, sizeof(zval*), NULL); + zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)&q, sizeof(zval*), NULL); } zend_hash_move_forward_ex(&class_type->default_static_members, &pos); } } - zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); + zend_hash_apply_with_argument(CE_STATIC_MEMBERS(class_type), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); *scope = old_scope; class_type->constants_updated = 1; http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.207.2.3&r2=1.207.2.4&ty=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.207.2.3 ZendEngine2/zend_API.h:1.207.2.4 --- ZendEngine2/zend_API.h:1.207.2.3 Fri Oct 28 10:46:29 2005 +++ ZendEngine2/zend_API.h Thu Dec 1 06:47:30 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.207.2.3 2005/10/28 14:46:29 dmitry Exp $ */ +/* $Id: zend_API.h,v 1.207.2.4 2005/12/01 11:47:30 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -146,6 +146,12 @@ #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) +#ifdef ZTS +# define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members:CG(static_members)[(long)(ce)->static_members]) +#else +# define CE_STATIC_MEMBERS(ce) ((ce)->static_members) +#endif + int zend_next_free_module(void); BEGIN_EXTERN_C() http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.6&r2=1.277.2.7&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.6 ZendEngine2/zend_builtin_functions.c:1.277.2.7 --- ZendEngine2/zend_builtin_functions.c:1.277.2.6 Thu Nov 24 00:07:27 2005 +++ ZendEngine2/zend_builtin_functions.c Thu Dec 1 06:47:30 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.277.2.6 2005/11/24 05:07:27 sebastian Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.277.2.7 2005/12/01 11:47:30 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" @@ -738,7 +738,7 @@ array_init(return_value); add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC); zend_update_class_constants(*pce TSRMLS_CC); - add_class_vars(*pce, (*pce)->static_members, return_value TSRMLS_CC); + add_class_vars(*pce, CE_STATIC_MEMBERS(*pce), return_value TSRMLS_CC); } } /* }}} */ http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.647.2.18&r2=1.647.2.19&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.18 ZendEngine2/zend_compile.c:1.647.2.19 --- ZendEngine2/zend_compile.c:1.647.2.18 Sun Nov 27 01:39:27 2005 +++ ZendEngine2/zend_compile.c Thu Dec 1 06:47:31 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.18 2005/11/27 06:39:27 iliaa Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.19 2005/12/01 11:47:31 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -2090,7 +2090,9 @@ if (parent_ce->type != ce->type) { /* User class extends internal class */ - ht = parent_ce->static_members; + TSRMLS_FETCH(); + + ht = CE_STATIC_MEMBERS(parent_ce); } else { ht = &parent_ce->default_static_members; } @@ -2196,7 +2198,7 @@ if (parent_ce->type != ce->type) { /* User class extends internal class */ zend_update_class_constants(parent_ce TSRMLS_CC); - zend_hash_merge(&ce->default_static_members, parent_ce->static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); + zend_hash_merge(&ce->default_static_members, CE_STATIC_MEMBERS(parent_ce), (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); } else { zend_hash_merge(&ce->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); } @@ -4026,7 +4028,23 @@ zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0); zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); - ce->static_members = (ce->type == ZEND_INTERNAL_CLASS) ? NULL : &ce->default_static_members; + if (ce->type == ZEND_INTERNAL_CLASS) { +#ifdef ZTS + int n = zend_hash_num_elements(CG(class_table)); + + if (CG(static_members) && n >= CG(last_static_member)) { + /* Support for run-time declaration: dl() */ + CG(last_static_member) = n+1; + CG(static_members) = realloc(CG(static_members), (n+1)*sizeof(HashTable*)); + CG(static_members)[n] = NULL; + } + ce->static_members = (HashTable*)n; +#else + ce->static_members = NULL; +#endif + } else { + ce->static_members = &ce->default_static_members; + } if (nullify_handlers) { ce->constructor = NULL; http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.141.2.1&r2=1.141.2.2&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.141.2.1 ZendEngine2/zend_globals.h:1.141.2.2 --- ZendEngine2/zend_globals.h:1.141.2.1 Tue Nov 15 08:29:28 2005 +++ ZendEngine2/zend_globals.h Thu Dec 1 06:47:33 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.141.2.1 2005/11/15 13:29:28 dmitry Exp $ */ +/* $Id: zend_globals.h,v 1.141.2.2 2005/12/01 11:47:33 dmitry Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -144,6 +144,11 @@ zend_encoding_converter encoding_converter; zend_encoding_oddlen encoding_oddlen; #endif /* ZEND_MULTIBYTE */ + +#ifdef ZTS + HashTable **static_members; + int last_static_member; +#endif }; http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.135.2.4&r2=1.135.2.5&ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.135.2.4 ZendEngine2/zend_object_handlers.c:1.135.2.5 --- ZendEngine2/zend_object_handlers.c:1.135.2.4 Wed Nov 16 06:52:27 2005 +++ ZendEngine2/zend_object_handlers.c Thu Dec 1 06:47:33 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.135.2.4 2005/11/16 11:52:27 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.135.2.5 2005/12/01 11:47:33 dmitry Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -857,7 +857,7 @@ zend_update_class_constants(tmp_ce TSRMLS_CC); - zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); + zend_hash_quick_find(CE_STATIC_MEMBERS(tmp_ce), property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); if (!retval) { if (silent) { http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.110.2.1&r2=1.110.2.2&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.110.2.1 ZendEngine2/zend_opcode.c:1.110.2.2 --- ZendEngine2/zend_opcode.c:1.110.2.1 Thu Sep 1 06:05:32 2005 +++ ZendEngine2/zend_opcode.c Thu Dec 1 06:47:34 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.110.2.1 2005/09/01 10:05:32 dmitry Exp $ */ +/* $Id: zend_opcode.c,v 1.110.2.2 2005/12/01 11:47:34 dmitry Exp $ */ #include <stdio.h> @@ -138,18 +138,20 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) { - if ((*pce)->static_members) { - if ((*pce)->static_members != &(*pce)->default_static_members) { - zend_hash_destroy((*pce)->static_members); - FREE_HASHTABLE((*pce)->static_members); - } - (*pce)->static_members = NULL; - } if ((*pce)->type == ZEND_USER_CLASS) { /* Clean all parts that can contain run-time data */ /* Note that only run-time accessed data need to be cleaned up, pre-defined data can not contain objects and thus are not probelmatic */ zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC); + (*pce)->static_members = NULL; + } else if (CE_STATIC_MEMBERS(*pce)) { + zend_hash_destroy(CE_STATIC_MEMBERS(*pce)); + FREE_HASHTABLE(CE_STATIC_MEMBERS(*pce)); +#ifdef ZTS + CG(static_members)[(long)((*pce)->static_members)] = NULL; +#else + (*pce)->static_members = NULL; +#endif } return 0; }