diff options
author | Andi Gutmans <andi@php.net> | 2004-07-10 07:46:17 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2004-07-10 07:46:17 +0000 |
commit | e5cfb1d05cf10fa694f231dae33ccb03ab8f74c8 (patch) | |
tree | 65252174d1cad948046778306ce3ba09d3d78682 /Zend | |
parent | 41b639fffebd099699cdf9c3231539d72602ce38 (diff) | |
download | php-git-e5cfb1d05cf10fa694f231dae33ccb03ab8f74c8.tar.gz |
- Better stability during premature shutdown of request startup
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_alloc.c | 2 | ||||
-rw-r--r-- | Zend/zend_hash.c | 28 | ||||
-rw-r--r-- | Zend/zend_variables.c | 8 |
3 files changed, 23 insertions, 15 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 0fabed4dd2..ff80a702b1 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -75,7 +75,7 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC; #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); \ diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index fd518db340..065c9b4680 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -137,6 +137,7 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength) 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 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio 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 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio 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; } diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 51f51f8d8c..e6fbd5342c 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -140,14 +140,16 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC) 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: |