X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_pool_api.c;h=d1d76c31e17f7eb405f36b9254f03b75a789d658;hp=e67b142f5da7ebb29286a59125c82a542982a034;hb=01300e3808fec53def73a410233f68f36f292097;hpb=22616d7660e06425a33ffefe748d4aa6067c2a43 diff --git a/http_request_pool_api.c b/http_request_pool_api.c index e67b142..d1d76c3 100644 --- a/http_request_pool_api.c +++ b/http_request_pool_api.c @@ -86,7 +86,7 @@ PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool TSRMLS_SET_CTX(pool->tsrm_ls); -#if HTTP_HAVE_EVENT +#ifdef HTTP_HAVE_EVENT pool->timeout = ecalloc(1, sizeof(struct event)); curl_multi_setopt(pool->ch, CURLMOPT_SOCKETDATA, pool); curl_multi_setopt(pool->ch, CURLMOPT_SOCKETFUNCTION, http_request_pool_socket_callback); @@ -297,10 +297,12 @@ PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool) fprintf(stderr, "Destructing request pool %p\n", pool); #endif -#if HTTP_HAVE_EVENT +#ifdef HTTP_HAVE_EVENT efree(pool->timeout); #endif + http_request_pool_detach_all(pool); + pool->unfinished = 0; zend_llist_clean(&pool->finished); zend_llist_clean(&pool->handles); @@ -316,6 +318,13 @@ PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool) /* {{{ STATUS http_request_pool_select(http_request_pool *) */ PHP_HTTP_API STATUS _http_request_pool_select(http_request_pool *pool) +{ + return http_request_pool_select_ex(pool, NULL); +} +/* }}} */ + +/* {{{ STATUS http_request_pool_select_ex(http_request_pool *, struct timeval *) */ +PHP_HTTP_API STATUS _http_request_pool_select_ex(http_request_pool *pool, struct timeval *custom_timeout) { int MAX; fd_set R, W, E; @@ -329,7 +338,11 @@ PHP_HTTP_API STATUS _http_request_pool_select(http_request_pool *pool) } #endif - http_request_pool_timeout(pool, &timeout); + if (custom_timeout && timerisset(custom_timeout)) { + timeout = *custom_timeout; + } else { + http_request_pool_timeout(pool, &timeout); + } FD_ZERO(&R); FD_ZERO(&W); @@ -382,9 +395,8 @@ void _http_request_pool_responsehandler(http_request_pool *pool) msg = curl_multi_info_read(pool->ch, &remaining); if (msg && CURLMSG_DONE == msg->msg) { if (CURLE_OK != msg->data.result) { - http_request *r = NULL; - curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &r); - http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(msg->data.result), r?r->_error:"", r?r->url:""); + http_request_storage *st = http_request_storage_get(msg->easy_handle); + http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(msg->data.result), st?st->errorbuffer:"", st?st->url:""); } http_request_pool_apply_with_arg(pool, _http_request_pool_apply_responsehandler, msg->easy_handle); }