- finalize persistent handle support (probably)
[m6w6/ext-http] / http_request_pool_api.c
index 1c263aff4049bf3d87b7b7c78bc79e43e220ce8c..27e1f0d819e819dd0fa363bcfd04131369397dbd 100644 (file)
 
 #include "php_http_api.h"
 #include "php_http_exception_object.h"
+#include "php_http_persistent_handle_api.h"
 #include "php_http_request_api.h"
 #include "php_http_request_object.h"
 #include "php_http_request_pool_api.h"
 #include "php_http_requestpool_object.h"
-#include "php_http_persistent_handle_api.h"
 
 #ifndef HTTP_DEBUG_REQPOOLS
 #      define HTTP_DEBUG_REQPOOLS 0
 #endif
 
-#ifdef HTTP_HAVE_PERSISTENT_HANDLES
-#      define HTTP_CURL_MULTI_CTOR(ch) (SUCCESS == http_persistent_handle_acquire("http_request_pool", &(ch)))
-#      define HTTP_CURL_MULTI_DTOR(chp) http_persistent_handle_release("http_request_pool", (chp))
-#else
-#      define HTTP_CURL_MULTI_CTOR(ch) ((ch) = curl_multi_init())
-#      define HTTP_CURL_MULTI_DTOR(chp) curl_multi_cleanup(*(chp)); *(chp) = NULL
-#endif
-
 static int http_request_pool_compare_handles(void *h1, void *h2);
 
-#ifdef HTTP_HAVE_PERSISTENT_HANDLES
 PHP_MINIT_FUNCTION(http_request_pool)
 {
-       if (SUCCESS != http_persistent_handle_provide("http_request_pool", curl_multi_init, (http_persistent_handle_dtor) curl_multi_cleanup)) {
+       if (SUCCESS != http_persistent_handle_provide("http_request_pool", curl_multi_init, (http_persistent_handle_dtor) curl_multi_cleanup, NULL)) {
                return FAILURE;
        }
        return SUCCESS;
 }
-#endif
 
 /* {{{ http_request_pool *http_request_pool_init(http_request_pool *) */
 PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool TSRMLS_DC)
@@ -63,7 +53,7 @@ PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool
                pool->ch = NULL;
        }
 
-       if (!HTTP_CURL_MULTI_CTOR(pool->ch)) {
+       if (SUCCESS != http_persistent_handle_acquire("http_request_pool", &pool->ch)) {
                if (free_pool) {
                        efree(pool);
                }
@@ -259,7 +249,7 @@ PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool TSRMLS_DC)
        pool->unfinished = 0;
        zend_llist_clean(&pool->finished);
        zend_llist_clean(&pool->handles);
-       HTTP_CURL_MULTI_DTOR(&pool->ch);
+       http_persistent_handle_release("http_request_pool", &pool->ch);
 }
 /* }}} */