MFZE1: make sure the resource-list is always consistent during shutdown (Thies).

This commit is contained in:
Sebastian Bergmann 2002-04-19 16:53:36 +00:00
parent 2697ce689d
commit bf5bb84277
3 changed files with 19 additions and 24 deletions

View File

@ -653,6 +653,23 @@ ZEND_API void zend_hash_graceful_destroy(HashTable *ht)
SET_INCONSISTENT(HT_DESTROYED);
}
ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)
{
Bucket *p;
IS_CONSISTENT(ht);
p = ht->pListTail;
while (p != NULL) {
zend_hash_apply_deleter(ht, p);
p = ht->pListTail;
}
pefree(ht->arBuckets, ht->persistent);
SET_INCONSISTENT(HT_DESTROYED);
}
/* This is used to selectively delete certain entries from a hashtable.
* destruct() receives the data and decides if the entry should be deleted
* or not

View File

@ -119,6 +119,7 @@ typedef int (*apply_func_arg_t)(void *pDest, void *argument TSRMLS_DC);
typedef int (*apply_func_args_t)(void *pDest, int num_args, va_list args, zend_hash_key *hash_key);
ZEND_API void zend_hash_graceful_destroy(HashTable *ht);
ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht);
ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC);
ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC);
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);

View File

@ -230,30 +230,7 @@ int zend_init_rsrc_plist(TSRMLS_D)
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC)
{
Bucket *p, *q;
while (1) {
p = ht->pListTail;
if (!p) {
break;
}
q = p->pListLast;
if (q) {
q->pListNext = NULL;
}
ht->pListTail = q;
if (ht->pDestructor) {
zend_try {
ht->pDestructor(p->pData);
} zend_end_try();
}
if (!p->pDataPtr && p->pData) {
pefree(p->pData, ht->persistent);
}
pefree(p, ht->persistent);
}
pefree(ht->arBuckets, ht->persistent);
zend_hash_graceful_reverse_destroy(ht);
}