com php-src: Fixed resource destruction: Zend/zend_list.c Zend/zend_list.h Zend/zend_variables.c ext/mysql /php_mysql.c ext/standard/proc_open.c
| From: | Dmitry Stogov | Date: | Wed, 07 May 2014 22:48:31 +0000 |
| Subject: | com php-src: Fixed resource destruction: Zend/zend_list.c Zend/zend_list.h Zend/zend_variables.c ext/mysql /php_mysql.c ext/standard/proc_open.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78193@lists.php.net to get a copy of this message | ||
Commit: fa7008bb247240556b6bd5950576d3f455621f82
Author: Dmitry Stogov <dmitry@zend.com> Thu, 8 May 2014 02:48:31 +0400
Parents: 223df9ceea08a9b186f320114e40914552f48716
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fa7008bb247240556b6bd5950576d3f455621f82
Log:
Fixed resource destruction
Changed paths:
M Zend/zend_list.c
M Zend/zend_list.h
M Zend/zend_variables.c
M ext/mysql/php_mysql.c
M ext/standard/proc_open.c
Diff:
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 7892b70...7ebe9c1 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -46,13 +46,21 @@ ZEND_API zval *zend_list_insert(void *ptr, int type TSRMLS_DC)
ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC)
{
- if (GC_REFCOUNT(res) <= 0) {
+ if (--GC_REFCOUNT(res) <= 0) {
return zend_hash_index_del(&EG(regular_list), res->handle);
} else {
return SUCCESS;
}
}
+ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC)
+{
+ if (GC_REFCOUNT(res) <= 0) {
+ return zend_hash_index_del(&EG(regular_list), res->handle);
+ } else {
+ return SUCCESS;
+ }
+}
static void zend_resource_dtor(zend_resource *res TSRMLS_DC)
{
diff --git a/Zend/zend_list.h b/Zend/zend_list.h
index a9f96ad..c243b0d 100644
--- a/Zend/zend_list.h
+++ b/Zend/zend_list.h
@@ -66,9 +66,11 @@ int zend_init_rsrc_list_dtors(void);
void zend_destroy_rsrc_list_dtors(void);
ZEND_API zval *zend_list_insert(void *ptr, int type TSRMLS_DC);
+ZEND_API int _zend_list_free(zend_resource *res TSRMLS_DC);
ZEND_API int _zend_list_delete(zend_resource *res TSRMLS_DC);
ZEND_API int _zend_list_close(zend_resource *res TSRMLS_DC);
+#define zend_list_free(res) _zend_list_free(res TSRMLS_CC)
#define zend_list_delete(res) _zend_list_delete(res TSRMLS_CC)
#define zend_list_close(res) _zend_list_close(res TSRMLS_CC)
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index fcb0dd1..ccdef22 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -70,7 +70,7 @@ ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
if (--GC_REFCOUNT(res) == 0) {
/* destroy resource */
- zend_list_delete(res);
+ zend_list_free(res);
}
break;
}
@@ -129,7 +129,7 @@ ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
TSRMLS_FETCH();
/* destroy resource */
- zend_list_delete(res);
+ zend_list_free(res);
break;
}
case IS_REFERENCE: {
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 0b27f1e..94bfb6c 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -427,9 +427,7 @@ static void _free_mysql_result(zend_resource *rsrc TSRMLS_DC)
static void php_mysql_set_default_link(zend_resource *link TSRMLS_DC)
{
if (MySG(default_link) != NULL) {
- if (--GC_REFCOUNT((MySG(default_link))) == 0) {
- zend_list_delete(MySG(default_link));
- }
+ zend_list_delete(MySG(default_link));
}
++GC_REFCOUNT(link);
MySG(default_link) = link;
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 0ab8ffa..2fb5553c 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -222,9 +222,7 @@ static void proc_open_rsrc_dtor(zend_resource *rsrc TSRMLS_DC)
/* Close all handles to avoid a deadlock */
for (i = 0; i < proc->npipes; i++) {
if (proc->pipes[i] != 0) {
- if (--GC_REFCOUNT(proc->pipes[i]) <= 0) {
- zend_list_delete(proc->pipes[i]);
- }
+ zend_list_delete(proc->pipes[i]);
proc->pipes[i] = 0;
}
}