]> granicus.if.org Git - apache/commitdiff
ping tuning via Yann Ylavic <ylavic.dev@gmail.com>
authorJim Jagielski <jim@apache.org>
Wed, 9 Oct 2013 13:38:45 +0000 (13:38 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 9 Oct 2013 13:38:45 +0000 (13:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1530603 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_ajp.c
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

index e4cccdacde159b24ddff0f635123fec53529145a..9e627b45106d8628ae7e2778ceb5757c17d59e0f 100644 (file)
@@ -341,7 +341,9 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
          * we assume it is a request that cause a back-end timeout,
          * but doesn't affect the whole worker.
          */
-        if (APR_STATUS_IS_TIMEUP(status) && conn->worker->s->ping_timeout_set) {
+        if (APR_STATUS_IS_TIMEUP(status) &&
+            conn->worker->s->ping_timeout_set &&
+            conn->worker->s->ping_timeout >= 0) {
             return HTTP_GATEWAY_TIME_OUT;
         }
 
@@ -661,7 +663,9 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
              * we assume it is a request that cause a back-end timeout,
              * but doesn't affect the whole worker.
              */
-            if (APR_STATUS_IS_TIMEUP(status) && conn->worker->s->ping_timeout_set) {
+            if (APR_STATUS_IS_TIMEUP(status) &&
+                conn->worker->s->ping_timeout_set &&
+                conn->worker->s->ping_timeout >= 0) {
                 apr_table_set(r->notes, "proxy_timedout", "1");
                 rv = HTTP_GATEWAY_TIME_OUT;
             }
index f22018addd7d441ec659bdf296e0838a23b2a053..da56543397759211295695e14f4c440bd62d772a 100644 (file)
@@ -1241,9 +1241,10 @@ int ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
     dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
 
     do_100_continue = (worker->s->ping_timeout_set
-                       && ap_request_has_body(r)
+                       && (worker->s->ping_timeout >= 0)
                        && (PROXYREQ_REVERSE == r->proxyreq)
-                       && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0")));
+                       && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0"))
+                       && ap_request_has_body(r));
 
     bb = apr_brigade_create(p, c->bucket_alloc);
     pass_bb = apr_brigade_create(p, c->bucket_alloc);
@@ -1973,17 +1974,21 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
                 apr_table_set(backend->connection->notes, "proxy-request-hostname",
                               ssl_hostname);
             }
-        }
 
-        /* Step Three-and-a-Half: See if the socket is still connected (if desired) */
-        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;
+            /* 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;
+            }
         }
 
         /* Step Four: Send the Request
@@ -1992,8 +1997,9 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker,
          */
         if ((status = ap_proxy_http_request(p, r, backend, worker,
                                         conf, uri, locurl, server_portstr)) != OK) {
-            if ((status == HTTP_SERVICE_UNAVAILABLE) && worker->s->ping_timeout_set &&
-                 worker->s->ping_timeout > 0) {
+            if ((status == HTTP_SERVICE_UNAVAILABLE) &&
+                 worker->s->ping_timeout_set &&
+                 worker->s->ping_timeout >= 0) {
                 backend->close = 1;
                 ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(01115)
                               "HTTP: 100-Continue failed to %pI (%s)",
index d2f7b70e8eec6304bc819ccaa881ea5f2a3b0f7b..d8f23da3ed11cd5c5d5c60d9b18c907e2100ba47 100644 (file)
@@ -3069,13 +3069,15 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
     proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
 
     /*
+     * HTTP "Ping" test? Easiest is 100-Continue. However:
      * To be compliant, we only use 100-Continue for requests with bodies.
      * We also make sure we won't be talking HTTP/1.0 as well.
      */
     do_100_continue = (worker->s->ping_timeout_set
-                       && ap_request_has_body(r)
+                       && (worker->s->ping_timeout >= 0)
                        && (PROXYREQ_REVERSE == r->proxyreq)
-                       && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0")));
+                       && !(apr_table_get(r->subprocess_env, "force-proxy-request-1.0")),
+                       && ap_request_has_body(r));
 
     if (apr_table_get(r->subprocess_env, "force-proxy-request-1.0")) {
         /*