diff options
author | Antony Dovgal <tony2001@php.net> | 2006-10-05 15:06:40 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-10-05 15:06:40 +0000 |
commit | a5d86612e3c7885ff65f46a5f59d0f71e068b71f (patch) | |
tree | 1f5317c95926cf8be353e1a4ba8e55a975d55d44 /ext/curl/multi.c | |
parent | 864f182def0292f048be48487873361e87d618f1 (diff) | |
download | php-git-a5d86612e3c7885ff65f46a5f59d0f71e068b71f.tar.gz |
MFH: decrement ch->uses (or destroy handle) when destroying multi handle
Diffstat (limited to 'ext/curl/multi.c')
-rw-r--r-- | ext/curl/multi.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 78387cd4af..d74711be47 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -62,7 +62,7 @@ PHP_FUNCTION(curl_multi_init) mh = ecalloc(1, sizeof(php_curlm)); mh->multi = curl_multi_init(); - zend_llist_init(&mh->easyh, sizeof(zval), (llist_dtor_func_t) NULL, 0); + zend_llist_init(&mh->easyh, sizeof(zval), _php_curl_multi_cleanup_list, 0); ZEND_REGISTER_RESOURCE(return_value, mh, le_curl_multi_handle); } @@ -98,6 +98,27 @@ PHP_FUNCTION(curl_multi_add_handle) } /* }}} */ +void _php_curl_multi_cleanup_list(void *data) /* {{{ */ +{ + zval *z_ch = (zval *)data; + php_curl *ch; + + if (!z_ch) { + return; + } + + ch = (php_curl *) zend_fetch_resource(&z_ch TSRMLS_CC, -1, le_curl_name, NULL, 1, le_curl); + if (!ch) { + return; + } + + if (ch->uses) { + ch->uses--; + } else { + zend_list_delete(Z_LVAL_P(z_ch)); + } +} +/* }}} */ /* Used internally as comparison routine passed to zend_list_del_element */ static int curl_compare_resources( zval *z1, zval **z2 ) |