You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2020/05/29 10:24:13 UTC

svn commit: r1878266 - in /httpd/httpd/branches/2.4.x: ./ CHANGES modules/http2/h2_proxy_session.c

Author: icing
Date: Fri May 29 10:24:13 2020
New Revision: 1878266

URL: http://svn.apache.org/viewvc?rev=1878266&view=rev
Log:
Merged /httpd/httpd/trunk:r1878233,1878264

  *) mod_proxy_http2: respect ProxyTimeout settings on backend connections
     while waiting on incoming data. [Ruediger Pluem, Stefan Eissing]


Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/modules/http2/h2_proxy_session.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1878233,1878264

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1878266&r1=1878265&r2=1878266&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Fri May 29 10:24:13 2020
@@ -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]

Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_proxy_session.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_proxy_session.c?rev=1878266&r1=1878265&r2=1878266&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_proxy_session.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_proxy_session.c Fri May 29 10:24:13 2020
@@ -902,7 +902,7 @@ static apr_status_t h2_proxy_session_rea
         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_strea
     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
 {
     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) {