diff options
| author | Pierrick Charron <pierrick@php.net> | 2013-01-05 11:07:59 -0500 |
|---|---|---|
| committer | Pierrick Charron <pierrick@php.net> | 2013-01-05 11:07:59 -0500 |
| commit | f85e5950ab4552799c119cd1d23617535ed19e61 (patch) | |
| tree | dffa4a4f032026df02d3a1baac9f7afacac84938 /ext/curl/multi.c | |
| parent | c4f2a20f150c6e2b453cdd16f5ca1715ab150f7a (diff) | |
| download | php-git-f85e5950ab4552799c119cd1d23617535ed19e61.tar.gz | |
Improve resource management for curl handle
Previous implementation was using its own refcounting (uses field of
the php_curl struct). zend_list_add/remove already implements its own
refcount, so we don't need to use an other one.
Diffstat (limited to 'ext/curl/multi.c')
| -rw-r--r-- | ext/curl/multi.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/ext/curl/multi.c b/ext/curl/multi.c index d84669a772..af78651ba1 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -86,7 +86,6 @@ PHP_FUNCTION(curl_multi_add_handle) ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl); _php_curl_cleanup_handle(ch); - ch->uses++; /* we want to create a copy of this zval that we store in the multihandle structure element "easyh" */ tmp_val = *z_ch; @@ -113,11 +112,7 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */ return; } - if (ch->uses) { - ch->uses--; - } else { - zend_list_delete(Z_LVAL_P(z_ch)); - } + zend_list_delete(Z_LVAL_P(z_ch)); } /* }}} */ @@ -146,12 +141,12 @@ PHP_FUNCTION(curl_multi_remove_handle) ZEND_FETCH_RESOURCE(mh, php_curlm *, &z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle); ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl); - --ch->uses; + + RETVAL_LONG((long) curl_multi_remove_handle(mh->multi, ch->cp)); zend_llist_del_element( &mh->easyh, &z_ch, (int (*)(void *, void *)) curl_compare_resources ); - - RETURN_LONG((long) curl_multi_remove_handle(mh->multi, ch->cp)); + } /* }}} */ |
