summaryrefslogtreecommitdiff
path: root/Zend/zend_list.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_list.c')
-rw-r--r--Zend/zend_list.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 8bc5161bda..f7cbfac89f 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -50,6 +50,37 @@ ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC)
}
}
+ZEND_API int _zend_list_close(zend_resource *res TSRMLS_DC)
+{
+ if (res->gc.refcount <= 0) {
+ return zend_list_delete(res);
+ } else if (res->type >= 0) {
+ zend_rsrc_list_dtors_entry *ld;
+
+ ld = zend_hash_index_find_ptr(&list_destructors, res->type);
+ if (ld) {
+ switch (ld->type) {
+ case ZEND_RESOURCE_LIST_TYPE_STD:
+ if (ld->list_dtor) {
+ (ld->list_dtor)(res->ptr);
+ }
+ break;
+ case ZEND_RESOURCE_LIST_TYPE_EX:
+ if (ld->list_dtor_ex) {
+ ld->list_dtor_ex(res TSRMLS_CC);
+ }
+ break;
+ EMPTY_SWITCH_DEFAULT_CASE()
+ }
+ } else {
+ zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)", res->type);
+ }
+ res->ptr = NULL;
+ res->type = -1;
+ }
+ return SUCCESS;
+}
+
ZEND_API zend_resource* zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC)
{
zval *zv;
@@ -124,26 +155,29 @@ ZEND_API void *zend_fetch_resource(zval *passed_id TSRMLS_DC, int default_id, co
void list_entry_destructor(zval *zv)
{
zend_resource *res = Z_RES_P(zv);
- zend_rsrc_list_dtors_entry *ld;
- TSRMLS_FETCH();
+
+ if (res->type >= 0) {
+ zend_rsrc_list_dtors_entry *ld;
+ TSRMLS_FETCH();
- ld = zend_hash_index_find_ptr(&list_destructors, res->type);
- if (ld) {
- switch (ld->type) {
- case ZEND_RESOURCE_LIST_TYPE_STD:
- if (ld->list_dtor) {
- (ld->list_dtor)(res->ptr);
- }
- break;
- case ZEND_RESOURCE_LIST_TYPE_EX:
- if (ld->list_dtor_ex) {
- ld->list_dtor_ex(res TSRMLS_CC);
- }
- break;
- EMPTY_SWITCH_DEFAULT_CASE()
+ ld = zend_hash_index_find_ptr(&list_destructors, res->type);
+ if (ld) {
+ switch (ld->type) {
+ case ZEND_RESOURCE_LIST_TYPE_STD:
+ if (ld->list_dtor) {
+ (ld->list_dtor)(res->ptr);
+ }
+ break;
+ case ZEND_RESOURCE_LIST_TYPE_EX:
+ if (ld->list_dtor_ex) {
+ ld->list_dtor_ex(res TSRMLS_CC);
+ }
+ break;
+ EMPTY_SWITCH_DEFAULT_CASE()
+ }
+ } else {
+ zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)", res->type);
}
- } else {
- zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)", res->type);
}
efree(res);
}