]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) back port: Add CPING to health check logic - remove hardcoded timeout.
authorGraham Leggett <minfrin@apache.org>
Mon, 5 Jul 2021 09:01:27 +0000 (09:01 +0000)
committerGraham Leggett <minfrin@apache.org>
Mon, 5 Jul 2021 09:01:27 +0000 (09:01 +0000)
     Trunk version of patch:
        https://svn.apache.org/r1887439
     Backport version for 2.4.x of patch:
      Trunk version of patch works
      svn merge -c 1887439 ^/httpd/httpd/trunk .
     +1: minfrin, rpluem, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1891276 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/proxy/mod_proxy_hcheck.c

diff --git a/STATUS b/STATUS
index 2a29b2c79b6d65bf5a5f7b1463375c499c4e574f..7470db90c1a9b6da1a9bcb36fa130fa99a6e8aae 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -142,13 +142,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) back port: Add CPING to health check logic - remove hardcoded timeout.
-     Trunk version of patch:
-        https://svn.apache.org/r1887439
-     Backport version for 2.4.x of patch:
-      Trunk version of patch works
-      svn merge -c 1887439 ^/httpd/httpd/trunk .
-     +1: minfrin, rpluem, covener
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index 9986f1a9bd78a72a41be05ace952410ad9a52168..b78147beeddc3c81218ef35e81b81675f826c0f0 100644 (file)
@@ -615,7 +615,7 @@ static int hc_get_backend(const char *proxy_function, proxy_conn_rec **backend,
     return hc_determine_connection(ctx, hc, &(*backend)->addr, ptemp);
 }
 
-static apr_status_t hc_check_cping(baton_t *baton)
+static apr_status_t hc_check_cping(baton_t *baton, apr_thread_t *thread)
 {
     int status;
     sctx_t *ctx = baton->ctx;
@@ -641,8 +641,18 @@ static apr_status_t hc_check_cping(baton_t *baton)
         return backend_cleanup("HCCPING", backend, ctx->s, status);
     }
     set_request_connection(r, backend->connection);
-
-    timeout = apr_time_from_sec(10); /* 10 seconds */
+    backend->connection->current_thread = thread;
+
+    if (hc->s->ping_timeout_set) {
+        timeout = hc->s->ping_timeout;
+    } else if ( hc->s->conn_timeout_set) {
+        timeout = hc->s->conn_timeout;
+    } else if ( hc->s->timeout_set) {
+        timeout = hc->s->timeout;
+    } else {
+        /* default to socket timeout */
+        apr_socket_timeout_get(backend->sock, &timeout); 
+    }
     status = ajp_handle_cping_cpong(backend->sock, r, timeout);
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, baton->ctx->s, "HCCPING done %d", status);
     return backend_cleanup("HCCPING", backend, ctx->s, status);
@@ -788,7 +798,7 @@ static int hc_read_body(request_rec *r, apr_bucket_brigade *bb)
  * then apply those to the resulting response, otherwise
  * any status code 2xx or 3xx is considered "passing"
  */
-static apr_status_t hc_check_http(baton_t *baton)
+static apr_status_t hc_check_http(baton_t *baton, apr_thread_t *thread)
 {
     int status;
     proxy_conn_rec *backend = NULL;
@@ -818,6 +828,7 @@ static apr_status_t hc_check_http(baton_t *baton)
         return backend_cleanup("HCOH", backend, ctx->s, status);
     }
     set_request_connection(r, backend->connection);
+    backend->connection->current_thread = thread;
 
     bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
 
@@ -884,10 +895,10 @@ static void * APR_THREAD_FUNC hc_check(apr_thread_t *thread, void *b)
         rv = hc_check_tcp(baton);
     }
     else if (hc->s->method == CPING) {
-        rv = hc_check_cping(baton);
+        rv = hc_check_cping(baton, thread);
     }
     else {
-        rv = hc_check_http(baton);
+        rv = hc_check_http(baton, thread);
     }
 
     now = apr_time_now();