From: Michael Wallner Date: Thu, 6 Nov 2014 10:13:32 +0000 (+0100) Subject: Merge branch 'R_2_1' X-Git-Tag: RELEASE_2_2_0_RC1~9^2~4 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=f27f09fb8025a8d640fdd283b25577956fee13f8;hp=-c Merge branch 'R_2_1' --- f27f09fb8025a8d640fdd283b25577956fee13f8 diff --combined php_http_client_curl.c index 9fc0291,48deae3..1f0e1aa --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@@ -282,7 -282,7 +282,7 @@@ static int php_http_curle_raw_callback( } else if (php_memnstr(data, ZEND_STRL("Operation timed out"), data + length)) { h->progress.info = "timeout"; } else { -#if PHP_DEBUG +#if 0 h->progress.info = data; data[length - 1] = '\0'; #endif @@@ -539,9 -539,11 +539,11 @@@ static STATUS php_http_curle_get_info(C case CURLSSLBACKEND_NSS: backend = "nss"; break; + #if !PHP_HTTP_CURL_VERSION(7,39,0) case CURLSSLBACKEND_QSOSSL: backend = "qsossl"; break; + #endif case CURLSSLBACKEND_GSKIT: backend = "gskit"; break; @@@ -783,6 -785,8 +785,6 @@@ static void php_http_curlm_timer_callba if (!event_initialized(curl->timeout)) { event_assign(curl->timeout, curl->evbase, CURL_SOCKET_TIMEOUT, 0, php_http_curlm_timeout_callback, context); - } else if (event_pending(curl->timeout, EV_TIMEOUT, NULL)) { - event_del(curl->timeout); } timeout.tv_sec = timeout_ms / 1000; @@@ -903,7 -907,7 +905,7 @@@ static STATUS php_http_curle_option_set return FAILURE; } } else { - if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMEVALUE, (long) PHP_HTTP_G->env.request.time + Z_LVAL_P(val))) { + if (CURLE_OK != curl_easy_setopt(ch, CURLOPT_TIMEVALUE, (long) sapi_get_request_time(TSRMLS_C) + Z_LVAL_P(val))) { return FAILURE; } } @@@ -1880,17 -1884,6 +1882,17 @@@ static void php_http_client_curl_reset( } } +static inline void php_http_client_curl_get_timeout(php_http_client_curl_t *curl, long max_tout, struct timeval *timeout) +{ + if ((CURLM_OK == curl_multi_timeout(curl->handle, &max_tout)) && (max_tout > 0)) { + timeout->tv_sec = max_tout / 1000; + timeout->tv_usec = (max_tout % 1000) * 1000; + } else { + timeout->tv_sec = 0; + timeout->tv_usec = 1000; + } +} + #ifdef PHP_WIN32 # define SELECT_ERROR SOCKET_ERROR #else @@@ -1906,18 -1899,10 +1908,18 @@@ static STATUS php_http_client_curl_wait #if PHP_HTTP_HAVE_EVENT if (curl->useevents) { - TSRMLS_FETCH_FROM_CTX(h->ts); + if (!event_initialized(curl->timeout)) { + event_assign(curl->timeout, curl->evbase, CURL_SOCKET_TIMEOUT, 0, php_http_curlm_timeout_callback, h); + } else if (custom_timeout && timerisset(custom_timeout)) { + event_add(curl->timeout, custom_timeout); + } else if (!event_pending(curl->timeout, EV_TIMEOUT, NULL)) { + php_http_client_curl_get_timeout(curl, 1000, &timeout); + event_add(curl->timeout, &timeout); + } - php_error_docref(NULL TSRMLS_CC, E_WARNING, "not implemented"); - return FAILURE; + event_base_loop(curl->evbase, EVLOOP_ONCE); + + return SUCCESS; } #endif @@@ -1929,7 -1914,15 +1931,7 @@@ if (custom_timeout && timerisset(custom_timeout)) { timeout = *custom_timeout; } else { - long max_tout = 1000; - - if ((CURLM_OK == curl_multi_timeout(curl->handle, &max_tout)) && (max_tout > 0)) { - timeout.tv_sec = max_tout / 1000; - timeout.tv_usec = (max_tout % 1000) * 1000; - } else { - timeout.tv_sec = 0; - timeout.tv_usec = 1000; - } + php_http_client_curl_get_timeout(curl, 1000, &timeout); } if (MAX == -1) { @@@ -1948,9 -1941,12 +1950,9 @@@ static int php_http_client_curl_once(ph #if PHP_HTTP_HAVE_EVENT if (curl->useevents) { - TSRMLS_FETCH_FROM_CTX(h->ts); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "not implemented"); - return FAILURE; - } + event_base_loop(curl->evbase, EVLOOP_NONBLOCK); + } else #endif - while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle, &curl->unfinished)); php_http_curlm_responsehandler(h);