You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2021/06/21 17:03:35 UTC

svn commit: r1890947 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_balancer.c modules/proxy/mod_proxy_hcheck.c

Author: minfrin
Date: Mon Jun 21 17:03:35 2021
New Revision: 1890947

URL: http://svn.apache.org/viewvc?rev=1890947&view=rev
Log:
*) back port: Add CPING to health check logic.
   Trunk version of patch:
        https://svn.apache.org/r1887415
   Backport version for 2.4.x of patch:
      Trunk version of patch works
      svn merge -c 1887415 ^/httpd/httpd/trunk .
   +1: jfclere, jim, minfrin


Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/CHANGES
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1887415

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Mon Jun 21 17:03:35 2021
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.49
 
+  *) Add CPING to health check logic. [Jean-Frederic Clere]
+
   *) core: Split ap_create_request() from ap_read_request(). [Graham Leggett]
 
   *) core, h2: common ap_parse_request_line() and ap_check_request_header()

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Jun 21 17:03:35 2021
@@ -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.
-     Trunk version of patch:
-        https://svn.apache.org/r1887415
-     Backport version for 2.4.x of patch:
-      Trunk version of patch works
-      svn merge -c 1887415 ^/httpd/httpd/trunk .
-     +1: jfclere, jim, minfrin
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Mon Jun 21 17:03:35 2021
@@ -562,6 +562,7 @@
  * 20120211.106 (2.4.49-dev) Add ap_create_request().
  * 20120211.107 (2.4.49-dev) Add ap_parse_request_line() and
  *                           ap_check_request_header()
+ * 20120211.108 (2.4.49-dev) Add ajp_handle_cping_cpong
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -569,7 +570,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 107                 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 108                 /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h Mon Jun 21 17:03:35 2021
@@ -1311,6 +1311,15 @@ APR_DECLARE_OPTIONAL_FN(int, ap_proxy_cl
         (request_rec *r, apr_table_t *headers));
 
 /**
+ * Do a AJP CPING and wait for CPONG on the socket
+ *
+ */
+APR_DECLARE_OPTIONAL_FN(apr_status_t, ajp_handle_cping_cpong,
+        (apr_socket_t *sock, request_rec *r,
+         apr_interval_time_t timeout));
+
+
+/**
  * @param socket        socket to test
  * @return              TRUE if socket is connected/active
  */

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c Mon Jun 21 17:03:35 2021
@@ -832,6 +832,7 @@ static void ap_proxy_http_register_hook(
 {
     proxy_hook_scheme_handler(proxy_ajp_handler, NULL, NULL, APR_HOOK_FIRST);
     proxy_hook_canon_handler(proxy_ajp_canon, NULL, NULL, APR_HOOK_FIRST);
+    APR_REGISTER_OPTIONAL_FN(ajp_handle_cping_cpong);
 }
 
 AP_DECLARE_MODULE(proxy_ajp) = {

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c Mon Jun 21 17:03:35 2021
@@ -1089,6 +1089,8 @@ static void push2table(const char *input
         }
         ap_unescape_url(key);
         ap_unescape_url(val);
+        /* hcuri, worker name, balancer name, at least  are escaped when building the form, so twice */
+        ap_unescape_url(val);
         if (allowed == NULL) { /* allow all */
             apr_table_set(params, key, val);
         }
@@ -1329,7 +1331,7 @@ static int balancer_handler(request_rec
                 *wsel->s->hcexpr = '\0';
         }
         /* If the health check method doesn't support an expr, then null it */
-        if (wsel->s->method == NONE || wsel->s->method == TCP) {
+        if (wsel->s->method == NONE || wsel->s->method == TCP || wsel->s->method == CPING) {
             *wsel->s->hcexpr = '\0';
         }
         /* if enabling, we need to reset all lb params */

Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c?rev=1890947&r1=1890946&r2=1890947&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c Mon Jun 21 17:03:35 2021
@@ -75,6 +75,8 @@ typedef struct {
     apr_time_t *now;
 } baton_t;
 
+static APR_OPTIONAL_FN_TYPE(ajp_handle_cping_cpong) *ajp_handle_cping_cpong = NULL;
+
 static void *hc_create_config(apr_pool_t *p, server_rec *s)
 {
     sctx_t *ctx = apr_pcalloc(p, sizeof(sctx_t));
@@ -613,6 +615,39 @@ static int hc_get_backend(const char *pr
     return hc_determine_connection(ctx, hc, &(*backend)->addr, ptemp);
 }
 
+static apr_status_t hc_check_cping(baton_t *baton)
+{
+    int status;
+    sctx_t *ctx = baton->ctx;
+    proxy_worker *hc = baton->hc;
+    proxy_conn_rec *backend = NULL;
+    apr_pool_t *ptemp = baton->ptemp;
+    request_rec *r;
+    apr_interval_time_t timeout;
+
+    if (!ajp_handle_cping_cpong) {
+        return APR_ENOTIMPL;
+    }
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, baton->ctx->s, "HCCPING starting");
+    if ((status = hc_get_backend("HCCPING", &backend, hc, ctx, baton->ptemp)) != OK) {
+        return backend_cleanup("HCCPING", backend, ctx->s, status);
+    }
+    if ((status = ap_proxy_connect_backend("HCCPING", backend, hc, ctx->s)) != OK) {
+        return backend_cleanup("HCCPING", backend, ctx->s, status);
+    }
+    r = create_request_rec(ptemp, ctx->s, baton->balancer, "CPING");
+    if ((status = ap_proxy_connection_create_ex("HCCPING", backend, r)) != OK) {
+        return backend_cleanup("HCCPING", backend, ctx->s, status);
+    }
+    set_request_connection(r, backend->connection);
+
+    timeout = apr_time_from_sec(10); /* 10 seconds */
+    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);
+}
+
 static apr_status_t hc_check_tcp(baton_t *baton)
 {
     int status;
@@ -848,6 +883,9 @@ static void * APR_THREAD_FUNC hc_check(a
     if (hc->s->method == TCP) {
         rv = hc_check_tcp(baton);
     }
+    else if (hc->s->method == CPING) {
+        rv = hc_check_cping(baton);
+    }
     else {
         rv = hc_check_http(baton);
     }
@@ -1075,6 +1113,18 @@ static int hc_post_config(apr_pool_t *p,
                      "watchdog callback registered (%s for %s)", HCHECK_WATHCHDOG_NAME, s->server_hostname);
         s = s->next;
     }
+
+    ajp_handle_cping_cpong = APR_RETRIEVE_OPTIONAL_FN(ajp_handle_cping_cpong);
+    if (ajp_handle_cping_cpong) {
+       proxy_hcmethods_t *method = proxy_hcmethods;
+       for (; method->name; method++) {
+           if (method->method == CPING) {
+               method->implemented = 1;
+               break;
+           }
+       }
+    }
+
     return OK;
 }
 



Re: svn commit: r1890947 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_balancer.c modules/proxy/mod_proxy_hcheck.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 22 Jun 2021, at 09:09, Ruediger Pluem <rp...@apache.org> wrote:

>> +    timeout = apr_time_from_sec(10); /* 10 seconds */
> 
> Sorry for jumping on this late, but as I already mentioned on the original trunk revision a hard coded timeout is bad.
> Please also backport r1887439. For the record I am +1 on backporting r1887439.

+1 to this.

I’ve proposed it here: http://svn.apache.org/viewvc?rev=1890960&view=rev <http://svn.apache.org/viewvc?rev=1890960&view=rev>

Regards,
Graham
—


Re: svn commit: r1890947 - in /httpd/httpd/branches/2.4.x: ./ CHANGES STATUS include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_balancer.c modules/proxy/mod_proxy_hcheck.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 6/21/21 7:03 PM, minfrin@apache.org wrote:
> Author: minfrin
> Date: Mon Jun 21 17:03:35 2021
> New Revision: 1890947
> 
> URL: http://svn.apache.org/viewvc?rev=1890947&view=rev
> Log:
> *) back port: Add CPING to health check logic.
>    Trunk version of patch:
>         https://svn.apache.org/r1887415
>    Backport version for 2.4.x of patch:
>       Trunk version of patch works
>       svn merge -c 1887415 ^/httpd/httpd/trunk .
>    +1: jfclere, jim, minfrin
> 
> 
> Modified:
>     httpd/httpd/branches/2.4.x/   (props changed)
>     httpd/httpd/branches/2.4.x/CHANGES
>     httpd/httpd/branches/2.4.x/STATUS
>     httpd/httpd/branches/2.4.x/include/ap_mmn.h
>     httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy.h
>     httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_ajp.c
>     httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_balancer.c
>     httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c
> 
> Propchange: httpd/httpd/branches/2.4.x/
> ------------------------------------------------------------------------------
>   Merged /httpd/httpd/trunk:r1887415
> 

> 
> Modified: httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c?rev=1890947&r1=1890946&r2=1890947&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c (original)
> +++ httpd/httpd/branches/2.4.x/modules/proxy/mod_proxy_hcheck.c Mon Jun 21 17:03:35 2021

> @@ -613,6 +615,39 @@ static int hc_get_backend(const char *pr
>      return hc_determine_connection(ctx, hc, &(*backend)->addr, ptemp);
>  }
>  
> +static apr_status_t hc_check_cping(baton_t *baton)
> +{
> +    int status;
> +    sctx_t *ctx = baton->ctx;
> +    proxy_worker *hc = baton->hc;
> +    proxy_conn_rec *backend = NULL;
> +    apr_pool_t *ptemp = baton->ptemp;
> +    request_rec *r;
> +    apr_interval_time_t timeout;
> +
> +    if (!ajp_handle_cping_cpong) {
> +        return APR_ENOTIMPL;
> +    }
> +
> +    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, baton->ctx->s, "HCCPING starting");
> +    if ((status = hc_get_backend("HCCPING", &backend, hc, ctx, baton->ptemp)) != OK) {
> +        return backend_cleanup("HCCPING", backend, ctx->s, status);
> +    }
> +    if ((status = ap_proxy_connect_backend("HCCPING", backend, hc, ctx->s)) != OK) {
> +        return backend_cleanup("HCCPING", backend, ctx->s, status);
> +    }
> +    r = create_request_rec(ptemp, ctx->s, baton->balancer, "CPING");
> +    if ((status = ap_proxy_connection_create_ex("HCCPING", backend, r)) != OK) {
> +        return backend_cleanup("HCCPING", backend, ctx->s, status);
> +    }
> +    set_request_connection(r, backend->connection);
> +
> +    timeout = apr_time_from_sec(10); /* 10 seconds */

Sorry for jumping on this late, but as I already mentioned on the original trunk revision a hard coded timeout is bad.
Please also backport r1887439. For the record I am +1 on backporting r1887439.

Regards

Rüdiger