- example
[m6w6/ext-http] / http_request_pool_api.c
index a38e73fc10f6f2f5a0148d97b0cf0f7aa0251ee3..7dc809ba665f60883958d4748d92abf006f857a6 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-
 #include "php.h"
+
+#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
+
 #include "php_http.h"
 #include "php_http_std_defs.h"
 #include "php_http_api.h"
@@ -28,8 +30,6 @@
 #include "php_http_request_object.h"
 #include "php_http_requestpool_object.h"
 
-#ifdef ZEND_ENGINE_2
-
 #ifndef HTTP_DEBUG_REQPOOLS
 #      define HTTP_DEBUG_REQPOOLS 0
 #endif
@@ -108,7 +108,7 @@ PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *req
 {
        getObjectEx(http_request_object, req, request);
 #if HTTP_DEBUG_REQPOOLS
-       fprintf(stderr, "Detaching request %p (pool: %p) from pool %p\n", req, req->pool, pool);
+       fprintf(stderr, "Detaching request %p from pool %p\n", req, pool);
 #endif
        if (req->pool != pool) {
                http_error(E_WARNING, HTTP_E_CURL, "HttpRequest object is not attached to this HttpRequestPool");
@@ -135,7 +135,7 @@ PHP_HTTP_API void _http_request_pool_detach_all(http_request_pool *pool TSRMLS_D
        fprintf(stderr, "Detaching %d requests from pool %p\n", count, pool);
 #endif
        /*
-        * we cannot apply a function to the llist which actually detaches 
+        * we cannot apply a function to the llist which actually detaches
         * the curl handle *and* removes the llist element --
         * so let's get our hands dirty
         */
@@ -143,13 +143,14 @@ PHP_HTTP_API void _http_request_pool_detach_all(http_request_pool *pool TSRMLS_D
                int i = 0;
                zend_llist_position pos;
                zval **handle, **handles = emalloc(count * sizeof(zval *));
-               
+
                for (handle = zend_llist_get_first_ex(&pool->handles, &pos); handle; handle = zend_llist_get_next_ex(&pool->handles, &pos)) {
                        handles[i++] = *handle;
                }
                for (i = 0; i < count; ++i) {
                        http_request_pool_detach(pool, handles[i]);
                }
+               efree(handles);
        }
 }
 
@@ -158,7 +159,7 @@ PHP_HTTP_API void _http_request_pool_detach_all(http_request_pool *pool TSRMLS_D
 PHP_HTTP_API STATUS _http_request_pool_send(http_request_pool *pool TSRMLS_DC)
 {
 #if HTTP_DEBUG_REQPOOLS
-       fprintf(stderr, "Attempt to send requests of pool %p\n", pool);
+       fprintf(stderr, "Attempt to send %d requests of pool %p\n", zend_llist_count(&pool->handles), pool);
 #endif
        while (http_request_pool_perform(pool)) {
 #if HTTP_DEBUG_REQPOOLS
@@ -239,7 +240,7 @@ static int http_request_pool_compare_handles(void *h1, void *h2)
 }
 /* }}} */
 
-#endif /* ZEND_ENGINE_2 */
+#endif /* ZEND_ENGINE_2 && HTTP_HAVE_CURL */
 
 
 /*