php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #51760
Patch zend_hash_init_MLK.diff revision 2010-05-06 21:57 UTC by russell dot tempero at rightnow dot com

Patch zend_hash_init_MLK.diff for Performance problem Bug #51760

Patch version 2010-05-06 21:57 UTC

Return to Bug #51760 | Download this patch
Patch Revisions:

Developer: russell.tempero@rightnow.com

Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /nfs/users/apiutil/rtempero/local/repositories/cvsroot/php-5.3.2/sapi/cgi/cgi_main.c,v
retrieving revision 1.6
diff -u -p -r1.6 cgi_main.c
--- sapi/cgi/cgi_main.c	3 May 2010 20:14:25 -0000	1.6
+++ sapi/cgi/cgi_main.c	5 May 2010 17:46:35 -0000
@@ -1430,12 +1430,20 @@ static void php_cgi_globals_ctor(php_cgi
 }
 /* }}} */
 
+/* {{{ php_cgi_globals_dtor
+ */
+static void php_cgi_globals_dtor(php_cgi_globals_struct *php_cgi_globals TSRMLS_DC)
+{
+	zend_hash_destroy(&php_cgi_globals->user_config_cache);
+}
+/* }}} */
+
 /* {{{ PHP_MINIT_FUNCTION
  */
 static PHP_MINIT_FUNCTION(cgi)
 {
 #ifdef ZTS
-	ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
+	ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, (ts_allocate_dtor) php_cgi_globals_dtor);
 #else
 	php_cgi_globals_ctor(&php_cgi_globals TSRMLS_CC);
 #endif
Index: Zend/zend_hash.c
===================================================================
RCS file: /nfs/users/apiutil/rtempero/local/repositories/cvsroot/php-5.3.2/Zend/zend_hash.c,v
retrieving revision 1.2
diff -u -p -r1.2 zend_hash.c
--- Zend/zend_hash.c	16 Apr 2010 17:24:51 -0000	1.2
+++ Zend/zend_hash.c	5 May 2010 17:50:23 -0000
@@ -530,7 +530,10 @@ ZEND_API void zend_hash_destroy(HashTabl
 		}
 		pefree(q, ht->persistent);
 	}
-	pefree(ht->arBuckets, ht->persistent);
+	if (ht->arBuckets) {
+		pefree(ht->arBuckets, ht->persistent);
+		ht->arBuckets = NULL;
+	}
 
 	SET_INCONSISTENT(HT_DESTROYED);
 }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC