fix crash when dtor is fialing on shutdown

This commit is contained in:
Stanislav Malyshev 2004-09-17 10:13:52 +00:00
parent 2a2d49b947
commit 3755c03291
3 changed files with 14 additions and 0 deletions

View File

@ -190,6 +190,9 @@ void init_executor(TSRMLS_D)
void shutdown_destructors(TSRMLS_D) {
zend_try {
zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
} zend_catch {
/* if we couldn't destruct cleanly, mark all objects as destructed anyway */
zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
} zend_end_try();
}

View File

@ -58,6 +58,16 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
}
}
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC)
{
zend_uint i = 1;
for (i = 1; i < objects->top ; i++) {
if (objects->object_buckets[i].valid) {
objects->object_buckets[i].destructor_called = 1;
}
}
}
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC)
{

View File

@ -57,6 +57,7 @@ typedef struct _zend_objects_store {
BEGIN_EXTERN_C()
ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint init_size);
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC);
ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects TSRMLS_DC);
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
/* Store API functions */