cvs: ZendEngine2 / zend_alloc.c zend_hash.c zend_variables.c
| From: | Andi Gutmans | Date: | Sat, 10 Jul 2004 07:45:50 +0000 |
| Subject: | cvs: ZendEngine2 / zend_alloc.c zend_hash.c zend_variables.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2725@lists.php.net to get a copy of this message | ||
andi Sat Jul 10 03:45:50 2004 EDT
Modified files:
/ZendEngine2 zend_alloc.c zend_hash.c zend_variables.c
Log:
- Better stability during premature shutdown of request startup
http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.c?r1=1.136&r2=1.137&ty=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.136 ZendEngine2/zend_alloc.c:1.137
--- ZendEngine2/zend_alloc.c:1.136 Fri Jul 2 20:16:39 2004
+++ ZendEngine2/zend_alloc.c Sat Jul 10 03:45:49 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.c,v 1.136 2004/07/03 00:16:39 andi Exp $ */
+/* $Id: zend_alloc.c,v 1.137 2004/07/10 07:45:49 andi Exp $ */
#include "zend.h"
#include "zend_alloc.h"
@@ -75,7 +75,7 @@
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
if (AG(memory_limit)<AG(allocated_memory)) {\
int php_mem_limit = AG(memory_limit); \
- if (AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
+ if (EG(in_execution) && AG(memory_limit)+1048576 > AG(allocated_memory) - rs) {
\
AG(memory_limit) = AG(allocated_memory) + 1048576; \
if (file) { \
zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to
allocate %d bytes)", php_mem_limit, file, lineno, s); \
http://cvs.php.net/diff.php/ZendEngine2/zend_hash.c?r1=1.114&r2=1.115&ty=u
Index: ZendEngine2/zend_hash.c
diff -u ZendEngine2/zend_hash.c:1.114 ZendEngine2/zend_hash.c:1.115
--- ZendEngine2/zend_hash.c:1.114 Thu Jan 8 12:31:47 2004
+++ ZendEngine2/zend_hash.c Sat Jul 10 03:45:49 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_hash.c,v 1.114 2004/01/08 17:31:47 sniper Exp $ */
+/* $Id: zend_hash.c,v 1.115 2004/07/10 07:45:49 andi Exp $ */
#include "zend.h"
@@ -137,6 +137,7 @@
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t
pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
{
uint i = 3;
+ Bucket **tmp;
SET_INCONSISTENT(HT_OK);
@@ -146,18 +147,8 @@
ht->nTableSize = 1 << i;
ht->nTableMask = ht->nTableSize - 1;
-
- /* Uses ecalloc() so that Bucket* == NULL */
- if (persistent) {
- ht->arBuckets = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
- if (!ht->arBuckets) {
- return FAILURE;
- }
- } else {
- ht->arBuckets = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
- }
-
ht->pDestructor = pDestructor;
+ ht->arBuckets = NULL;
ht->pListHead = NULL;
ht->pListTail = NULL;
ht->nNumOfElements = 0;
@@ -166,6 +157,21 @@
ht->persistent = persistent;
ht->nApplyCount = 0;
ht->bApplyProtection = 1;
+
+ /* Uses ecalloc() so that Bucket* == NULL */
+ if (persistent) {
+ tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
+ if (!tmp) {
+ return FAILURE;
+ }
+ ht->arBuckets = tmp;
+ } else {
+ tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
+ if (tmp) {
+ ht->arBuckets = tmp;
+ }
+ }
+
return SUCCESS;
}
http://cvs.php.net/diff.php/ZendEngine2/zend_variables.c?r1=1.56&r2=1.57&ty=u
Index: ZendEngine2/zend_variables.c
diff -u ZendEngine2/zend_variables.c:1.56 ZendEngine2/zend_variables.c:1.57
--- ZendEngine2/zend_variables.c:1.56 Wed Mar 24 05:55:04 2004
+++ ZendEngine2/zend_variables.c Sat Jul 10 03:45:49 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_variables.c,v 1.56 2004/03/24 10:55:04 dmitry Exp $ */
+/* $Id: zend_variables.c,v 1.57 2004/07/10 07:45:49 andi Exp $ */
#include <stdio.h>
#include "zend.h"
@@ -140,14 +140,16 @@
case IS_CONSTANT_ARRAY: {
zval *tmp;
HashTable *original_ht = zvalue->value.ht;
+ HashTable *tmp_ht = NULL;
TSRMLS_FETCH();
if (zvalue->value.ht == &EG(symbol_table)) {
return SUCCESS; /* do nothing */
}
- ALLOC_HASHTABLE_REL(zvalue->value.ht);
- zend_hash_init(zvalue->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(zvalue->value.ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *)
&tmp, sizeof(zval *));
+ ALLOC_HASHTABLE_REL(tmp_ht);
+ zend_hash_init(tmp_ht, 0, NULL, ZVAL_PTR_DTOR, 0);
+ zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp,
sizeof(zval *));
+ zvalue->value.ht = tmp_ht;
}
break;
case IS_OBJECT: