- due to the aggressive object deallocation the request object and its curl handle
authorMichael Wallner <mike@php.net>
Mon, 7 Nov 2005 22:15:42 +0000 (22:15 +0000)
committerMichael Wallner <mike@php.net>
Mon, 7 Nov 2005 22:15:42 +0000 (22:15 +0000)
  would already have been cleaned up when reaching curl_multi_remove_handle()
  when there's no additional reference to the request object (i.e. no user space
  reference to the attached request object);
  e.g.: $pool = new HttpRequestPool(new HttpRequest('...'))

http_request_pool_api.c
package2.xml

index 188bb9d326aea647f94dd678ea8463ef33c8e973..c3820c41ed305224063d91ce894855429e2c81ff 100644 (file)
@@ -28,7 +28,7 @@
 #include "php_http_requestpool_object.h"
 
 #ifndef HTTP_DEBUG_REQPOOLS
-#      define HTTP_DEBUG_REQPOOLS 0
+#      define HTTP_DEBUG_REQPOOLS 1
 #endif
 
 ZEND_EXTERN_MODULE_GLOBALS(http);
@@ -136,18 +136,18 @@ PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *req
        } else {
                CURLMcode code;
 
-               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);
-               
+               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);
+                       
 #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
                
-               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 {
                        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 FAILURE;
index 043d39802443a2f724cc5ce6caf8c106def09fb6..5ef731d678a6d08eb21e2a8829c9164f67d9d7eb 100644 (file)
@@ -41,6 +41,8 @@
  <notes><![CDATA[
 + Classes HttpMessage and HttpRequestPool implement Countable if PHP >= 5.1 with SPL is available
 + Class HttpMessage implements Serializable if PHP >= 5.1 is available
+
+* Fixed a bug that caused a warning about an invalid curl handle at HttpRequestPool destruction
 ]]></notes>
  <contents>
   <dir name="/">