diff options
author | Andi Gutmans <andi@php.net> | 2002-01-25 12:55:03 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2002-01-25 12:55:03 +0000 |
commit | 7309a6ed21b85771e478d0513dc13dfadceeae16 (patch) | |
tree | 19e8d6de785d10b7b820005964cce05e5f4b592a /Zend/zend_objects.c | |
parent | 96a9eba020f956e605d52a2a99e3975c7e9ae0da (diff) | |
download | php-git-7309a6ed21b85771e478d0513dc13dfadceeae16.tar.gz |
- First destructor hell fix. There was a situation where an object's
- destructor could be run after its class was already dead. Right now
- object destructors is the first thing whic happens during shutdown in
- order to prevent this problem. It's very likely that destructors will
- cause more grief and we'll have to outline exactly when you should use
- them and what kind of logic you're allowed to do inside of them.
- This bug was reported by sebastian.
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r-- | Zend/zend_objects.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 4ff6bab921..bdb77f05d0 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -27,7 +27,7 @@ void zend_objects_destroy(zend_objects *objects) efree(objects->object_buckets); } -static inline void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC) +static inline void zend_objects_call_destructor(zend_object *object, zend_object_handle handle TSRMLS_DC) { if (object->ce->destructor) { zval *obj; @@ -57,13 +57,33 @@ static inline void zend_objects_destroy_object(zend_object *object, zend_object_ zval_ptr_dtor(&destructor_func_name); zval_ptr_dtor(&retval_ptr); } +} + +static inline void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC) +{ + zend_objects_call_destructor(object, handle TSRMLS_CC); /* Nuke the object */ zend_hash_destroy(object->properties); efree(object->properties); } + +void zend_objects_call_destructors(zend_objects *objects TSRMLS_DC) +{ + int i = 1; + + for (i = 0; i < objects->top ; i++) { + if (EG(objects).object_buckets[i].valid) { + EG(objects).object_buckets[i].constructor_called = 1; + zend_objects_destroy_object(&EG(objects).object_buckets[i].bucket.obj.object, i TSRMLS_CC); + EG(objects).object_buckets[i].valid = 0; + } + } +} + + zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type) { zend_object_handle handle; |