Implement a more granular shutdown mechanism for the executor -

prevent corruption of constants and missing destructions of resources
This commit is contained in:
Zeev Suraski 2001-07-20 14:20:34 +00:00
parent 13ac04b8e5
commit 8084d27885
3 changed files with 62 additions and 34 deletions

View file

@ -536,9 +536,8 @@ void zend_deactivate(CLS_D ELS_DC)
if (setjmp(EG(bailout))==0) { if (setjmp(EG(bailout))==0) {
shutdown_scanner(CLS_C); shutdown_scanner(CLS_C);
} }
if (setjmp(EG(bailout))==0) { /* shutdown_executor() takes care of its own bailout handling */
shutdown_executor(ELS_C); shutdown_executor(ELS_C);
}
if (setjmp(EG(bailout))==0) { if (setjmp(EG(bailout))==0) {
shutdown_compiler(CLS_C); shutdown_compiler(CLS_C);
} }

View file

@ -152,6 +152,7 @@ void init_executor(CLS_D ELS_DC)
void shutdown_executor(ELS_D) void shutdown_executor(ELS_D)
{ {
if (setjmp(EG(bailout))==0) {
zend_ptr_stack_destroy(&EG(arg_types_stack)); zend_ptr_stack_destroy(&EG(arg_types_stack));
while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
@ -174,11 +175,13 @@ void shutdown_executor(ELS_D)
/* Destroy all op arrays */ /* Destroy all op arrays */
zend_hash_apply(EG(function_table), (int (*)(void *)) is_not_internal_function); zend_hash_apply(EG(function_table), (int (*)(void *)) is_not_internal_function);
zend_hash_apply(EG(class_table), (int (*)(void *)) is_not_internal_class); zend_hash_apply(EG(class_table), (int (*)(void *)) is_not_internal_class);
}
zend_destroy_rsrc_list(ELS_C); /* must be destroyed after the main symbol table and zend_destroy_rsrc_list(ELS_C); /* must be destroyed after the main symbol table and
* op arrays are destroyed. * op arrays are destroyed.
*/ */
if (setjmp(EG(bailout))==0) {
clean_non_persistent_constants(); clean_non_persistent_constants();
#if ZEND_DEBUG #if ZEND_DEBUG
signal(SIGSEGV, original_sigsegv_handler); signal(SIGSEGV, original_sigsegv_handler);
@ -195,6 +198,7 @@ void shutdown_executor(ELS_D)
zend_ptr_stack_destroy(&EG(user_error_handlers)); zend_ptr_stack_destroy(&EG(user_error_handlers));
EG(error_reporting) = EG(orig_error_reporting); EG(error_reporting) = EG(orig_error_reporting);
}
} }

View file

@ -231,10 +231,35 @@ int zend_init_rsrc_plist(ELS_D)
void zend_destroy_rsrc_list(ELS_D) void zend_destroy_rsrc_list(ELS_D)
{ {
zend_hash_reverse_destroy(&EG(regular_list)); Bucket *p, *q;
HashTable *ht = &EG(regular_list);
while (1) {
p = ht->pListTail;
if (!p) {
break;
}
q = p->pListLast;
if (q) {
q->pListNext = NULL;
}
ht->pListTail = q;
if (ht->pDestructor) {
if (setjmp(EG(bailout))==0) {
ht->pDestructor(p->pData);
}
}
if (!p->pDataPtr && p->pData) {
pefree(p->pData, ht->persistent);
}
pefree(p, ht->persistent);
}
pefree(ht->arBuckets, ht->persistent);
} }
void zend_destroy_rsrc_plist(ELS_D) void zend_destroy_rsrc_plist(ELS_D)
{ {
zend_hash_reverse_destroy(&EG(persistent_list)); zend_hash_reverse_destroy(&EG(persistent_list));