avoid recursive calls to the event loop dispatcher
authorMichael Wallner <mike@php.net>
Tue, 23 Aug 2016 11:37:53 +0000 (13:37 +0200)
committerMichael Wallner <mike@php.net>
Tue, 23 Aug 2016 11:37:53 +0000 (13:37 +0200)
src/php_http_client_curl.c

index 27ebd02682790897a238e4051efe7120cdd58a5b..b15fdd47f6c84475be23ff4026816eaf9503af5b 100644 (file)
@@ -2251,19 +2251,21 @@ static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h)
        php_http_client_curl_t *curl = h->ctx;
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
-       if (curl->ev_ops) {
-               return curl->ev_ops->exec(curl->ev_ctx);
-       }
+       if (!h->callback.depth) {
+               if (curl->ev_ops) {
+                       return curl->ev_ops->exec(curl->ev_ctx);
+               }
 
-       while (php_http_client_curl_once(h) && !EG(exception)) {
-               if (SUCCESS != php_http_client_curl_wait(h, NULL)) {
+               while (php_http_client_curl_once(h) && !EG(exception)) {
+                       if (SUCCESS != php_http_client_curl_wait(h, NULL)) {
 #ifdef PHP_WIN32
-                       /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError());
+                               /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError());
 #else
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 #endif
-                       return FAILURE;
+                               return FAILURE;
+                       }
                }
        }