cvs: Zend(PHP_4_3) / zend_alloc.c zend_hash.c zend_variables.c
| From: | Ilia Alshanetsky | Date: | Mon, 12 Jul 2004 21:26:47 +0000 |
| Subject: | cvs: Zend(PHP_4_3) / 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-2731@lists.php.net to get a copy of this message | ||
iliaa Mon Jul 12 17:26:47 2004 EDT
Modified files: (Branch: PHP_4_3)
/Zend zend_alloc.c zend_hash.c zend_variables.c
Log:
MFHZE2: Better stability during premature shutdown of request startup
http://cvs.php.net/diff.php/Zend/zend_alloc.c?r1=1.105.4.5&r2=1.105.4.6&ty=u
Index: Zend/zend_alloc.c
diff -u Zend/zend_alloc.c:1.105.4.5 Zend/zend_alloc.c:1.105.4.6
--- Zend/zend_alloc.c:1.105.4.5 Mon May 17 09:15:14 2004
+++ Zend/zend_alloc.c Mon Jul 12 17:26:46 2004
@@ -67,7 +67,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/Zend/zend_hash.c?r1=1.87.4.5&r2=1.87.4.6&ty=u
Index: Zend/zend_hash.c
diff -u Zend/zend_hash.c:1.87.4.5 Zend/zend_hash.c:1.87.4.6
--- Zend/zend_hash.c:1.87.4.5 Tue Aug 12 02:22:05 2003
+++ Zend/zend_hash.c Mon Jul 12 17:26:46 2004
@@ -174,6 +174,7 @@
ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t
pDestructor, int persistent)
{
uint i = 3;
+ Bucket **tmp;
SET_INCONSISTENT(HT_OK);
@@ -183,14 +184,6 @@
ht->nTableSize = 1 << i;
ht->nTableMask = ht->nTableSize - 1;
-
- /* Uses ecalloc() so that Bucket* == NULL */
- ht->arBuckets = (Bucket **) pecalloc(ht->nTableSize, sizeof(Bucket *), persistent);
-
- if (!ht->arBuckets) {
- return FAILURE;
- }
-
ht->pDestructor = pDestructor;
ht->pListHead = NULL;
ht->pListTail = NULL;
@@ -200,6 +193,16 @@
ht->persistent = persistent;
ht->nApplyCount = 0;
ht->bApplyProtection = 1;
+ ht->arBuckets = NULL;
+
+ /* Uses ecalloc() so that Bucket* == NULL */
+ tmp = (Bucket **) pecalloc(ht->nTableSize, sizeof(Bucket *), persistent);
+
+ if (!tmp) {
+ return FAILURE;
+ }
+ ht->arBuckets = tmp;
+
return SUCCESS;
}
http://cvs.php.net/diff.php/Zend/zend_variables.c?r1=1.44.2.1&r2=1.44.2.2&ty=u
Index: Zend/zend_variables.c
diff -u Zend/zend_variables.c:1.44.2.1 Zend/zend_variables.c:1.44.2.2
--- Zend/zend_variables.c:1.44.2.1 Tue Dec 31 11:23:05 2002
+++ Zend/zend_variables.c Mon Jul 12 17:26:46 2004
@@ -114,27 +114,31 @@
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: {
zval *tmp;
HashTable *original_ht = zvalue->value.obj.properties;
+ HashTable *tmp_ht = NULL;
TSRMLS_FETCH();
if (zvalue->value.obj.properties == &EG(symbol_table)) {
return SUCCESS; /* do nothing */
}
- ALLOC_HASHTABLE_REL(zvalue->value.obj.properties);
- zend_hash_init(zvalue->value.obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(zvalue->value.obj.properties, 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.obj.properties = tmp_ht;
}
break;
}