X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_pool_api.c;h=27e1f0d819e819dd0fa363bcfd04131369397dbd;hp=154161404a4f3d0cb8f9c6cf9f1df4770ff6c59f;hb=65cf6ca09489451473d9aba81f22895058403ca8;hpb=aebfa7783e7b280bff4975649b20494e5eb932bc diff --git a/http_request_pool_api.c b/http_request_pool_api.c index 1541614..27e1f0d 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2006, Michael Wallner | + | Copyright (c) 2004-2007, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -19,6 +19,7 @@ #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" @@ -28,12 +29,16 @@ # define HTTP_DEBUG_REQPOOLS 0 #endif -#ifndef HAVE_CURL_MULTI_STRERROR -# define curl_multi_strerror(dummy) "unknown error" -#endif - static int http_request_pool_compare_handles(void *h1, void *h2); +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, NULL)) { + return FAILURE; + } + return SUCCESS; +} + /* {{{ 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) { @@ -48,8 +53,7 @@ PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool pool->ch = NULL; } - HTTP_CHECK_CURL_INIT(pool->ch, curl_multi_init(), ;); - if (!pool->ch) { + if (SUCCESS != http_persistent_handle_acquire("http_request_pool", &pool->ch)) { if (free_pool) { efree(pool); } @@ -245,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); - curl_multi_cleanup(pool->ch); + http_persistent_handle_release("http_request_pool", &pool->ch); } /* }}} */