From: Michael Wallner Date: Tue, 8 Nov 2005 08:25:34 +0000 (+0000) Subject: - ensure detaching the request from the handles list is the last op X-Git-Tag: RELEASE_0_18_0~28 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4e3211cfb2655e91693bbb139e3a32fb6825830d;p=m6w6%2Fext-http - ensure detaching the request from the handles list is the last op - add test --- diff --git a/http_request_pool_api.c b/http_request_pool_api.c index 839cea2..9abbc3a 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -120,6 +120,7 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req /* {{{ STATUS http_request_pool_detach(http_request_pool *, zval *) */ PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *request TSRMLS_DC) { + CURLMcode code; getObjectEx(http_request_object, req, request); #if HTTP_DEBUG_REQPOOLS @@ -133,22 +134,18 @@ PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *req #endif } else if (req->pool != pool) { http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "HttpRequest object(#%d) is not attached to this HttpRequestPool", Z_OBJ_HANDLE_P(request)); + } else if (CURLM_OK != (code = curl_multi_remove_handle(pool->ch, req->ch))) { + http_error_ex(HE_WARNING, HTTP_E_REQUEST_POOL, "Could not detach HttpRequest object from the HttpRequestPool: %s", curl_multi_strerror(code)); } else { - CURLMcode code; - - if (CURLM_OK == (code = curl_multi_remove_handle(pool->ch, req->ch))) { - req->pool = NULL; - zend_llist_del_element(&pool->handles, request, http_request_pool_compare_handles); - zend_llist_del_element(&pool->finished, request, http_request_pool_compare_handles); - + req->pool = NULL; + zend_llist_del_element(&pool->finished, request, http_request_pool_compare_handles); + zend_llist_del_element(&pool->handles, request, http_request_pool_compare_handles); + #if HTTP_DEBUG_REQPOOLS - fprintf(stderr, "> %d HttpRequests remaining in pool %p\n", zend_llist_count(&pool->handles), pool); + fprintf(stderr, "> %d HttpRequests remaining in pool %p\n", zend_llist_count(&pool->handles), pool); #endif - - return SUCCESS; - } else { - http_error_ex(HE_WARNING, HTTP_E_REQUEST_POOL, "Could not detach HttpRequest object from the HttpRequestPool: %s", curl_multi_strerror(code)); - } + + return SUCCESS; } return FAILURE; } diff --git a/package2.xml b/package2.xml index 5ef731d..c502b43 100644 --- a/package2.xml +++ b/package2.xml @@ -165,6 +165,7 @@ + @@ -252,7 +253,7 @@ default="no" /> diff --git a/tests/HttpRequestPool_004.phpt b/tests/HttpRequestPool_004.phpt new file mode 100644 index 0000000..baafe8a --- /dev/null +++ b/tests/HttpRequestPool_004.phpt @@ -0,0 +1,19 @@ +--TEST-- +HttpRequestPool::__destruct() invalid curl handle +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +%sTEST +Done