diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2004-03-11 00:11:18 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2004-03-11 00:11:18 +0000 |
| commit | 21a7e57ae732dbacc663d2bca21425afe5e21d94 (patch) | |
| tree | 01e8f44a0eed0c44f2201ee1f8d05da5654909bf /ext/curl | |
| parent | a5fec66463b6a82f1ca4ff01df769d797697f905 (diff) | |
| download | php-git-21a7e57ae732dbacc663d2bca21425afe5e21d94.tar.gz | |
Fixed memory leak in the multi interface.
Fixed proto of curl_multi_exec().
Fixed crash in curl resource attached to curl multi resource is manually
freed via curl_close().
Diffstat (limited to 'ext/curl')
| -rw-r--r-- | ext/curl/interface.c | 7 | ||||
| -rw-r--r-- | ext/curl/multi.c | 10 | ||||
| -rw-r--r-- | ext/curl/php_curl.h | 1 |
3 files changed, 13 insertions, 5 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 0bd32cb705..9bb17beb12 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1333,8 +1333,11 @@ PHP_FUNCTION(curl_close) } ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl); - - zend_list_delete(Z_LVAL_PP(zid)); + if (ch->uses) { + ch->uses--; + } else { + zend_list_delete(Z_LVAL_PP(zid)); + } } /* }}} */ diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 34e60f81a7..c5f48bdfdc 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -62,6 +62,8 @@ 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) ZVAL_PTR_DTOR, 0); + ZEND_REGISTER_RESOURCE(return_value, mh, le_curl_multi_handle); } /* }}} */ @@ -86,7 +88,9 @@ PHP_FUNCTION(curl_multi_add_handle) _php_curl_cleanup_handle(ch); ch->uses++; - + + zend_llist_add_element(&(*mh).easyh, &z_ch); + RETURN_LONG((long) curl_multi_add_handle(mh->multi, ch->cp)); } /* }}} */ @@ -152,7 +156,7 @@ PHP_FUNCTION(curl_multi_select) } /* }}} */ -/* {{{ proto int curl_multi_exec(resource mh) +/* {{{ proto int curl_multi_exec(resource mh, int &still_running) Run the sub-connections of the current cURL handle */ PHP_FUNCTION(curl_multi_exec) { @@ -252,10 +256,10 @@ void _php_curl_multi_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) php_curlm *mh = (php_curlm *) rsrc->ptr; if (mh) { curl_multi_cleanup(mh->multi); + zend_llist_clean(&(*mh).easyh); efree(mh); rsrc->ptr = NULL; } - /* XXX: keep track of all curl handles and zval_ptr_dtor them here */ } #endif diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index ebd344758e..3e9b9e2cf8 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -125,6 +125,7 @@ typedef struct { typedef struct { int still_running; CURLM *multi; + zend_llist easyh; } php_curlm; void _php_curl_cleanup_handle(php_curl *); |
