cvs: ZendEngine2(PHP_5_1) / zend.c
| From: | Dmitry Stogov | Date: | Mon, 12 Sep 2005 09:06:18 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_1) / zend.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4112@lists.php.net to get a copy of this message | ||
dmitry Mon Sep 12 05:06:18 2005 EDT
Modified files: (Branch: PHP_5_1)
/ZendEngine2 zend.c
Log:
Fixed huge memory leak in ZTS mode (backport from HEAD)
http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.308&r2=1.308.2.1&ty=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.308 ZendEngine2/zend.c:1.308.2.1
--- ZendEngine2/zend.c:1.308 Wed Aug 3 09:30:45 2005
+++ ZendEngine2/zend.c Mon Sep 12 05:06:15 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.c,v 1.308 2005/08/03 13:30:45 sniper Exp $ */
+/* $Id: zend.c,v 1.308.2.1 2005/09/12 09:06:15 dmitry Exp $ */
#include "zend.h"
#include "zend_extensions.h"
@@ -38,6 +38,7 @@
# define GLOBAL_FUNCTION_TABLE CG(function_table)
# define GLOBAL_CLASS_TABLE CG(class_table)
# define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals)
+# define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
#endif
#if defined(ZEND_WIN32) && ZEND_DEBUG
@@ -88,6 +89,7 @@
HashTable *global_class_table;
HashTable *global_constants_table;
HashTable *global_auto_globals_table;
+static HashTable *global_persistent_list = NULL;
#endif
ZEND_API zend_utility_values zend_uv;
@@ -486,6 +488,13 @@
static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC)
{
zend_ini_shutdown(TSRMLS_C);
+ if (&executor_globals->persistent_list != global_persistent_list) {
+ zend_destroy_rsrc_list(&executor_globals->persistent_list TSRMLS_CC);
+ }
+ if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) {
+ zend_hash_destroy(executor_globals->zend_constants);
+ free(executor_globals->zend_constants);
+ }
}
@@ -682,6 +691,7 @@
compiler_globals_ctor(compiler_globals, tsrm_ls);
free(EG(zend_constants));
executor_globals_ctor(executor_globals, tsrm_ls);
+ global_persistent_list = &EG(persistent_list);
zend_new_thread_end_handler(tsrm_thread_id() TSRMLS_CC);
}
#endif
@@ -692,9 +702,6 @@
#ifdef ZEND_WIN32
zend_shutdown_timeout_thread();
#endif
-#ifndef ZTS
- zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
-#endif
zend_hash_graceful_reverse_destroy(&module_registry);
zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
@@ -706,16 +713,18 @@
zend_shutdown_extensions(TSRMLS_C);
free(zend_version_info);
- zend_shutdown_constants(TSRMLS_C);
free(GLOBAL_FUNCTION_TABLE);
free(GLOBAL_CLASS_TABLE);
-#ifdef ZTS
- zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
+
zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
free(GLOBAL_CONSTANTS_TABLE);
+
+ zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
+#ifdef ZTS
GLOBAL_FUNCTION_TABLE = NULL;
GLOBAL_CLASS_TABLE = NULL;
GLOBAL_AUTO_GLOBALS_TABLE = NULL;
+ GLOBAL_CONSTANTS_TABLE = NULL;
#endif
zend_destroy_rsrc_list_dtors();
}