From e5df73ae2e31faa4e5a7de57409734f4cecd4c4a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 23 Aug 2016 11:50:08 +0200 Subject: [PATCH] avoid recursive calls to the event loop dispatcher --- package.xml | 2 +- php_http.h | 2 +- src/php_http_client_curl.c | 15 ++++++++------- tests/client030.phpt | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 tests/client030.phpt diff --git a/package.xml b/package.xml index d22b029..352bf47 100644 --- a/package.xml +++ b/package.xml @@ -33,7 +33,7 @@ https://mdref.m6w6.name/http 2016-08-22 - 2.6.0beta1 + 2.6.0beta2 2.6.0 diff --git a/php_http.h b/php_http.h index 4f3e4e0..eb022ef 100644 --- a/php_http.h +++ b/php_http.h @@ -13,7 +13,7 @@ #ifndef PHP_EXT_HTTP_H #define PHP_EXT_HTTP_H -#define PHP_PECL_HTTP_VERSION "2.6.0beta1" +#define PHP_PECL_HTTP_VERSION "2.6.0beta2" extern zend_module_entry http_module_entry; #define phpext_http_ptr &http_module_entry diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index 1ec6624..27ebd02 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -2233,16 +2233,17 @@ static int php_http_client_curl_once(php_http_client_t *h) { php_http_client_curl_t *curl = h->ctx; - if (curl->ev_ops) { - curl->ev_ops->once(curl->ev_ctx); - } else { - while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle->multi, &curl->unfinished)); - } + if (!h->callback.depth) { + if (curl->ev_ops) { + curl->ev_ops->once(curl->ev_ctx); + } else { + while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle->multi, &curl->unfinished)); + } - php_http_client_curl_responsehandler(h); + php_http_client_curl_responsehandler(h); + } return curl->unfinished; - } static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h) diff --git a/tests/client030.phpt b/tests/client030.phpt new file mode 100644 index 0000000..582087f --- /dev/null +++ b/tests/client030.phpt @@ -0,0 +1,35 @@ +--TEST-- +client eventloop recursion +--SKIPIF-- + +--FILE-- +once(); + } +} +server("proxy.inc", function($port) { + $client = new http\Client; + $client->configure([ + "use_eventloop" => true, + ]); + $client->attach(new test); + $client->enqueue(new http\Client\Request("GET", "http://localhost:$port/"), function($r) { + var_dump($r->getResponseCode()); + }); + $client->send(); +}); + +?> +===DONE=== +--EXPECTF-- +Test +int(200) +===DONE=== \ No newline at end of file -- 2.30.2