httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1729507 - in /httpd/httpd/trunk/modules: http2/mod_proxy_http2.c proxy/mod_proxy.c proxy/mod_proxy.h proxy/mod_proxy_ajp.c proxy/mod_proxy_http.c proxy/mod_proxy_wstunnel.c
Date Tue, 09 Feb 2016 23:38:59 GMT
Author: ylavic
Date: Tue Feb  9 23:38:59 2016
New Revision: 1729507

URL: http://svn.apache.org/viewvc?rev=1729507&view=rev
Log:
mod_proxy: axe negative "ping" parameter setting and handling.
This used to check for the backend connection readability only (instead of
the full ping/100-continue round-trip), but the case is already handled by
ap_proxy_connect_backend() which is always called.

Modified:
    httpd/httpd/trunk/modules/http2/mod_proxy_http2.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c

Modified: httpd/httpd/trunk/modules/http2/mod_proxy_http2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/mod_proxy_http2.c?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/mod_proxy_http2.c (original)
+++ httpd/httpd/trunk/modules/http2/mod_proxy_http2.c Tue Feb  9 23:38:59 2016
@@ -211,9 +211,9 @@ static int proxy_http2_handler(request_r
 {
     const char *proxy_function;
     proxy_conn_rec *backend;
-    char *locurl = url, *u, *firsturl;
+    char *locurl = url, *u;
     apr_size_t slen;
-    int is_ssl = 0, retry = 0;
+    int is_ssl = 0;
     int flushall = 0;
     int status;
     char server_portstr[32];
@@ -268,7 +268,7 @@ static int proxy_http2_handler(request_r
         ap_proxy_ssl_connection_cleanup(backend, r);
     }
 
-    while (retry < 2) {
+    do { /* while (0): break out */
         conn_rec *backconn;
         
         /* Step One: Determine the URL to connect to (might be a proxy),
@@ -288,18 +288,6 @@ static int proxy_http2_handler(request_r
             ssl_hostname = apr_pstrdup(r->pool, backend->ssl_hostname);
         }
         
-        if (!retry) {
-            firsturl = locurl;
-            /* http does a prefetch here, so that it immediately can start sending
-             * when the backend connection comes online. This minimizes the risk of
-             * reusing a connection only to experience a keepalive close.
-             */
-        }
-        else {
-            /* On a retry, we'd expect to see the same url again */
-            AP_DEBUG_ASSERT(strcmp(firsturl, locurl) == 0);
-        }
-
         /* Step Two: Make the Connection (or check that an already existing
          * socket is still usable). On success, we have a socket connected to
          * backend->hostname. */
@@ -339,21 +327,6 @@ static int proxy_http2_handler(request_r
                 apr_table_setn(backend->connection->notes,
                                "proxy-request-alpn-protos", "h2");
             }
-            
-            /* Step Three-and-a-Half: See if the socket is still connected (if
-             * desired). Note: Since ap_proxy_connect_backend just above does
-             * the same check (unconditionally), this step is not required when
-             * backend's socket/connection is reused (ie. no Step Three).
-             */
-            if (worker->s->ping_timeout_set && worker->s->ping_timeout
< 0 &&
-                !ap_proxy_is_socket_connected(backend->sock)) {
-                backend->close = 1;
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO()
-                              "socket check failed to %pI (%s)",
-                              worker->cp->addr, worker->s->hostname);
-                retry++;
-                continue;
-            }
         }
 
         /* Step Four: Send the Request in a new HTTP/2 stream and
@@ -370,8 +343,7 @@ static int proxy_http2_handler(request_r
                 proxy_run_detach_backend(r, backend);
             }
         }
-        break;
-    }
+    } while (0);
 
     /* clean up before return */
 cleanup:

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Feb  9 23:38:59 2016
@@ -280,7 +280,7 @@ static const char *set_worker_param(apr_
          */
         if (ap_timeout_parameter_parse(val, &timeout, "s") != APR_SUCCESS)
             return "Ping/Pong timeout has wrong format";
-        if (timeout < 1000 && timeout >= 0)
+        if (timeout < 1000)
             return "Ping/Pong timeout must be at least one millisecond";
         worker->s->ping_timeout = timeout;
         worker->s->ping_timeout_set = 1;

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Feb  9 23:38:59 2016
@@ -365,7 +365,6 @@ do {                             \
 
 #define PROXY_DO_100_CONTINUE(w, r) \
 ((w)->s->ping_timeout_set \
- && ((w)->s->ping_timeout >= 0) \
  && (PROXYREQ_REVERSE == (r)->proxyreq) \
  && !(apr_table_get((r)->subprocess_env, "force-proxy-request-1.0")) \
  && ap_request_has_body((r)))

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c Tue Feb  9 23:38:59 2016
@@ -342,8 +342,7 @@ static int ap_proxy_ajp_request(apr_pool
          * but doesn't affect the whole worker.
          */
         if (APR_STATUS_IS_TIMEUP(status) &&
-            conn->worker->s->ping_timeout_set &&
-            conn->worker->s->ping_timeout >= 0) {
+                conn->worker->s->ping_timeout_set) {
             return HTTP_GATEWAY_TIME_OUT;
         }
 
@@ -680,8 +679,7 @@ static int ap_proxy_ajp_request(apr_pool
              * but doesn't affect the whole worker.
              */
             if (APR_STATUS_IS_TIMEUP(status) &&
-                conn->worker->s->ping_timeout_set &&
-                conn->worker->s->ping_timeout >= 0) {
+                    conn->worker->s->ping_timeout_set) {
                 apr_table_setn(r->notes, "proxy_timedout", "1");
                 rv = HTTP_GATEWAY_TIME_OUT;
             }
@@ -791,35 +789,22 @@ static int proxy_ajp_handler(request_rec
 
         /* Handle CPING/CPONG */
         if (worker->s->ping_timeout_set) {
-            if (worker->s->ping_timeout < 0) {
-                if (!ap_proxy_is_socket_connected(backend->sock)) {
-                    backend->close = 1;
-                    ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02534)
-                                  "socket check failed to %pI (%s)",
-                                  worker->cp->addr, worker->s->hostname);
-                    status = HTTP_SERVICE_UNAVAILABLE;
-                    retry++;
-                    continue;
-                }
-            }
-            else {
-                status = ajp_handle_cping_cpong(backend->sock, r,
-                                                worker->s->ping_timeout);
-                /*
-                 * In case the CPING / CPONG failed for the first time we might be
-                 * just out of luck and got a faulty backend connection, but the
-                 * backend might be healthy nevertheless. So ensure that the backend
-                 * TCP connection gets closed and try it once again.
-                 */
-                if (status != APR_SUCCESS) {
-                    backend->close = 1;
-                    ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00897)
-                                  "cping/cpong failed to %pI (%s)",
-                                  worker->cp->addr, worker->s->hostname);
-                    status = HTTP_SERVICE_UNAVAILABLE;
-                    retry++;
-                    continue;
-                }
+            status = ajp_handle_cping_cpong(backend->sock, r,
+                                            worker->s->ping_timeout);
+            /*
+             * In case the CPING / CPONG failed for the first time we might be
+             * just out of luck and got a faulty backend connection, but the
+             * backend might be healthy nevertheless. So ensure that the backend
+             * TCP connection gets closed and try it once again.
+             */
+            if (status != APR_SUCCESS) {
+                backend->close = 1;
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00897)
+                              "cping/cpong failed to %pI (%s)",
+                              worker->cp->addr, worker->s->hostname);
+                status = HTTP_SERVICE_UNAVAILABLE;
+                retry++;
+                continue;
             }
         }
         /* Step Three: Process the Request */

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_http.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_http.c?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_http.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_http.c Tue Feb  9 23:38:59 2016
@@ -2097,21 +2097,6 @@ static int proxy_http_handler(request_re
                                "proxy-request-hostname",
                                backend->ssl_hostname);
             }
-
-            /* Step Three-and-a-Half: See if the socket is still connected (if
-             * desired). Note: Since ap_proxy_connect_backend just above does
-             * the same check (unconditionally), this step is not required when
-             * backend's socket/connection is reused (ie. no Step Three).
-             */
-            if (worker->s->ping_timeout_set && worker->s->ping_timeout
< 0 &&
-                    !ap_proxy_is_socket_connected(backend->sock)) {
-                backend->close = 1;
-                ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(02535)
-                              "socket check failed to %pI (%s)",
-                              worker->cp->addr, worker->s->hostname);
-                retry++;
-                continue;
-            }
         }
 
         /* Don't recycle the connection if prefetch (above) told not to do so */
@@ -2130,8 +2115,7 @@ static int proxy_http_handler(request_re
                                             flushall)) != OK) {
             proxy_run_detach_backend(r, backend);
             if ((status == HTTP_SERVICE_UNAVAILABLE) &&
-                 worker->s->ping_timeout_set &&
-                 worker->s->ping_timeout >= 0) {
+                    worker->s->ping_timeout_set) {
                 backend->close = 1;
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(01115)
                               "HTTP: 100-Continue failed to %pI (%s)",

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c?rev=1729507&r1=1729506&r2=1729507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_wstunnel.c Tue Feb  9 23:38:59 2016
@@ -421,7 +421,6 @@ static int proxy_wstunnel_handler(reques
     proxy_conn_rec *backend = NULL;
     const char *upgrade;
     char *scheme;
-    int retry;
     conn_rec *c = r->connection;
     apr_pool_t *p = r->pool;
     apr_uri_t *uri;
@@ -463,15 +462,13 @@ static int proxy_wstunnel_handler(reques
     backend->is_ssl = is_ssl;
     backend->close = 0;
 
-    retry = 0;
-    while (retry < 2) {
+    do { /* while (0): break out */
         char *locurl = url;
         /* Step One: Determine Who To Connect To */
         status = ap_proxy_determine_connection(p, r, conf, worker, backend,
                                                uri, &locurl, proxyname, proxyport,
                                                server_portstr,
                                                sizeof(server_portstr));
-
         if (status != OK)
             break;
 
@@ -495,8 +492,7 @@ static int proxy_wstunnel_handler(reques
         /* Step Three: Process the Request */
         status = proxy_wstunnel_request(p, r, backend, worker, conf, uri, locurl,
                                       server_portstr, scheme);
-        break;
-    }
+    } while (0);
 
     /* Do not close the socket */
     if (status != SUSPENDED) { 



Mime
View raw message