mirror of
https://github.com/php/php-src.git
synced 2025-01-19 02:03:47 +08:00
MFZE1: make sure the resource-list is always consistent during shutdown (Thies).
This commit is contained in:
parent
2697ce689d
commit
bf5bb84277
@ -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
|
||||
|
@ -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, ...);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user