From: Stefan Eissing Date: Fri, 29 May 2020 10:24:13 +0000 (+0000) Subject: Merged /httpd/httpd/trunk:r1878233,1878264 X-Git-Tag: 2.4.44~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fc58951d713f03dd18da8a905b51ed8d1c7699a;p=thirdparty%2Fapache%2Fhttpd.git Merged /httpd/httpd/trunk:r1878233,1878264 *) mod_proxy_http2: respect ProxyTimeout settings on backend connections while waiting on incoming data. [Ruediger Pluem, Stefan Eissing] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1878266 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 53aa374f9b0..8530fff127b 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Changes with Apache 2.4.44 *) core: httpd is no longer linked against -lsystemd if mod_systemd is enabled (and built as a DSO). [Rainer Jung] + *) mod_proxy_http2: respect ProxyTimeout settings on backend connections + while waiting on incoming data. [Ruediger Pluem, Stefan Eissing] + Changes with Apache 2.4.43 *) mod_ssl: Fix memory leak of OCSP stapling response. [Yann Ylavic] diff --git a/modules/http2/h2_proxy_session.c b/modules/http2/h2_proxy_session.c index 97a4a2a784c..fc659b8bf0c 100644 --- a/modules/http2/h2_proxy_session.c +++ b/modules/http2/h2_proxy_session.c @@ -902,7 +902,7 @@ static apr_status_t h2_proxy_session_read(h2_proxy_session *session, int block, apr_socket_t *socket = NULL; apr_time_t save_timeout = -1; - if (block) { + if (block && timeout > 0) { socket = ap_get_conn_socket(session->c); if (socket) { apr_socket_timeout_get(socket, &save_timeout); @@ -974,6 +974,14 @@ static void stream_resume(h2_proxy_stream *stream) dispatch_event(session, H2_PROXYS_EV_STREAM_RESUMED, 0, NULL); } +static int is_waiting_for_backend(h2_proxy_session *session) +{ + return (session->check_ping + || ((session->suspended->nelts <= 0) + && !nghttp2_session_want_write(session->ngh2) + && nghttp2_session_want_read(session->ngh2))); +} + static apr_status_t check_suspended(h2_proxy_session *session) { h2_proxy_stream *stream; @@ -1391,6 +1399,7 @@ apr_status_t h2_proxy_session_process(h2_proxy_session *session) { apr_status_t status; int have_written = 0, have_read = 0; + apr_interval_time_t timeout; ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c, "h2_proxy_session(%s): process", session->id); @@ -1428,7 +1437,36 @@ run_loop: break; case H2_PROXYS_ST_WAIT: - if (check_suspended(session) == APR_EAGAIN) { + if (is_waiting_for_backend(session)) { + /* + * We can do a blocking read. There is nothing we want to + * send or check until we get more data from the backend. + * The timeout used is either the one currently on the socket + * as indicated by a passed value of 0 or the ping timeout + * set via the ping parameter on the worker if set and if + * we are waiting for a ping. + * The timeout on the socket is configured via + * Timeout -> ProxyTimeout -> timeout parameter on the used + * worker with the later ones taking precedence. + */ + if (session->check_ping + && session->p_conn->worker->s->ping_timeout_set) { + timeout = session->p_conn->worker->s->ping_timeout; + } + else { + timeout = 0; + } + status = h2_proxy_session_read(session, 1, timeout); + if (status == APR_SUCCESS) { + have_read = 1; + dispatch_event(session, H2_PROXYS_EV_DATA_READ, 0, NULL); + } + else { + dispatch_event(session, H2_PROXYS_EV_CONN_ERROR, status, NULL); + return status; + } + } + else if (check_suspended(session) == APR_EAGAIN) { /* no stream has become resumed. Do a blocking read with * ever increasing timeouts... */ if (session->wait_timeout < 25) {