com php-src: Fixed clone refcount: ext/curl/interface.c ext/curl/php_curl.h
| From: | Xinchen Hui | Date: | Fri, 09 May 2014 06:00:47 +0000 |
| Subject: | com php-src: Fixed clone refcount: ext/curl/interface.c ext/curl/php_curl.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78220@lists.php.net to get a copy of this message | ||
Commit: 2d9bc88db8caebd44d81cbdfbcb109cf3bdfbca8
Author: Xinchen Hui <laruence@php.net> Fri, 9 May 2014 14:00:47 +0800
Parents: 564db38dc48e3b8c5a7f39decda3e92ea68ff894
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2d9bc88db8caebd44d81cbdfbcb109cf3bdfbca8
Log:
Fixed clone refcount
Changed paths:
M ext/curl/interface.c
M ext/curl/php_curl.h
Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index ad4367e..7c1cd30 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -1980,7 +1980,7 @@ PHP_FUNCTION(curl_copy_handle)
dupch->to_free = ch->to_free;
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
- ZVAL_COPY(&dupch->clone, &ch->clone);
+ ch->clone++;
ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
dupch->res = Z_RES_P(return_value);
@@ -2583,8 +2583,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue
TSRMLS_DC) /
return FAILURE;
}
- if (Z_REFCOUNTED(ch->clone) && Z_REFCOUNT(ch->clone) <= 1) {
+ if (ch->clone == 0) {
zend_llist_clean(&ch->to_free->post);
+ } else {
+ --ch->clone;
}
zend_llist_add_element(&ch->to_free->post, &first);
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first);
@@ -3167,14 +3169,14 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
curl_easy_cleanup(ch->cp);
/* cURL destructors should be invoked only by last curl handle */
- if (Z_ISUNDEF(ch->clone)) {
+ if (ch->clone == 0) {
zend_llist_clean(&ch->to_free->str);
zend_llist_clean(&ch->to_free->post);
zend_hash_destroy(ch->to_free->slist);
efree(ch->to_free->slist);
efree(ch->to_free);
} else {
- //??? Z_DELREF(ch->clone);
+ --ch->clone;
}
smart_str_free(&ch->handlers->write->buf);
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 018add5..3994ca9 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -180,7 +180,7 @@ typedef struct {
php_curl_handlers *handlers;
zend_resource *res;
zend_bool in_callback;
- zval clone;
+ zend_uint clone;
zend_bool safe_upload;
} php_curl;