httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1722195 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h mod_proxy_hcheck.c proxy_util.c
Date Tue, 29 Dec 2015 17:42:20 GMT
Author: jim
Date: Tue Dec 29 17:42:19 2015
New Revision: 1722195

URL: http://svn.apache.org/viewvc?rev=1722195&view=rev
Log:
Make aware of new status: Failed Health Check.
Store the number of current passes/fails in shm

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1722195&r1=1722194&r2=1722195&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Dec 29 17:42:19 2015
@@ -270,8 +270,11 @@ struct proxy_conn_pool {
     proxy_conn_rec *conn;   /* Single connection for prefork mpm */
 };
 
-/* Keep below in sync with proxy_util.c! */
 /* worker status bits */
+/*
+ * NOTE: Keep up-to-date w/ proxy_wstat_tbl[]
+ * in proxy_util.c !
+ */
 #define PROXY_WORKER_INITIALIZED    0x0001
 #define PROXY_WORKER_IGNORE_ERRORS  0x0002
 #define PROXY_WORKER_DRAIN          0x0004
@@ -282,6 +285,7 @@ struct proxy_conn_pool {
 #define PROXY_WORKER_IN_ERROR       0x0080
 #define PROXY_WORKER_HOT_STANDBY    0x0100
 #define PROXY_WORKER_FREE           0x0200
+#define PROXY_WORKER_HC_FAIL        0x0400
 
 /* worker status flags */
 #define PROXY_WORKER_INITIALIZED_FLAG    'O'
@@ -294,9 +298,11 @@ struct proxy_conn_pool {
 #define PROXY_WORKER_IN_ERROR_FLAG       'E'
 #define PROXY_WORKER_HOT_STANDBY_FLAG    'H'
 #define PROXY_WORKER_FREE_FLAG           'F'
+#define PROXY_WORKER_HC_FAIL_FLAG        '#'
 
 #define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
-PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
+PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR | \
+PROXY_WORKER_HC_FAIL )
 
 /* NOTE: these check the shared status */
 #define PROXY_WORKER_IS_INITIALIZED(f)  ( (f)->s->status &  PROXY_WORKER_INITIALIZED
)
@@ -371,7 +377,9 @@ typedef struct {
     int             index;      /* shm array index */
     int             method;     /* method to use for health check */
     int             passes;     /* number of successes for check to pass */
-    int             fails;       /* number of failures for check to fail */
+    int             pcount;     /* current count of passes */
+    int             fails;      /* number of failures for check to fail */
+    int             fcount;     /* current count of failures */
     proxy_hashes    hash;       /* hash of worker name */
     unsigned int    status;     /* worker status bitfield */
     enum {

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c?rev=1722195&r1=1722194&r2=1722195&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c Tue Dec 29 17:42:19 2015
@@ -16,6 +16,8 @@
 
 #include "mod_proxy.h"
 #include "mod_watchdog.h"
+#include "ap_slotmem.h"
+
 
 module AP_MODULE_DECLARE_DATA proxy_hcheck_module;
 
@@ -29,14 +31,14 @@ static char *methods[] = {
       "NULL", "OPTIONS", "HEAD", "GET", "POST", "CPING"
 };
 
-typedef struct hcheck_template_t {
+typedef struct hc_template_t {
     char *name;
     int method;
     int passes;
     int fails;
     apr_interval_time_t interval;
     char *hurl;
-} hcheck_template_t;
+} hc_template_t;
 
 static apr_pool_t *ptemplate = NULL;
 static apr_array_header_t *templates = NULL;
@@ -54,15 +56,15 @@ static const char *set_worker_hc_param(a
                                     void *tmp)
 {
     int ival;
-    hcheck_template_t *ctx;
+    hc_template_t *ctx;
 
     if (!worker && !tmp) {
         return "Bad call to set_worker_hc_param()";
     }
-    ctx = (hcheck_template_t *)tmp;
+    ctx = (hc_template_t *)tmp;
     if (!strcasecmp(key, "hcheck")) {
-        hcheck_template_t *template;
-        template = (hcheck_template_t *)templates->elts;
+        hc_template_t *template;
+        template = (hc_template_t *)templates->elts;
         for (ival = 0; ival < templates->nelts; ival++, template++) {
             if (!ap_casecmpstr(template->name, val)) {
                 worker->s->method = template->method;
@@ -138,8 +140,8 @@ static const char *set_hcheck(cmd_parms
 {
     char *name = NULL;
     char *word, *val;
-    hcheck_template_t template;
-    hcheck_template_t *tpush;
+    hc_template_t template;
+    hc_template_t *tpush;
     const char *err = ap_check_cmd_context(cmd, NOT_IN_HTACCESS);
     if (err)
         return err;
@@ -162,8 +164,8 @@ static const char *set_hcheck(cmd_parms
         if (err)
             return apr_pstrcat(cmd->temp_pool, "HCheckTemplate: ", err, " ", word, "=",
val, "; ", name, NULL);
         /* No error means we have a valid template */
-        tpush = (hcheck_template_t *)apr_array_push(templates);
-        memcpy(tpush, &template, sizeof(hcheck_template_t));
+        tpush = (hc_template_t *)apr_array_push(templates);
+        memcpy(tpush, &template, sizeof(hc_template_t));
     }
 
     return NULL;
@@ -207,7 +209,7 @@ static int hc_pre_config(apr_pool_t *p,
         apr_pool_create(&ptemplate, p);
     }
     if (!templates) {
-        templates = apr_array_make(ptemplate, 10, sizeof(hcheck_template_t));
+        templates = apr_array_make(ptemplate, 10, sizeof(hc_template_t));
     }
     return OK;
 }
@@ -259,7 +261,7 @@ static const command_rec command_table[]
 
 static void hc_register_hooks(apr_pool_t *p)
 {
-    static const char *const runAfter[] = { "mod_watchdog.c", NULL};
+    static const char *const runAfter[] = { "mod_watchdog.c", "mod_proxy_balancer.c", NULL};
     APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
     ap_hook_pre_config(hc_pre_config, NULL, NULL, APR_HOOK_LAST);
     ap_hook_post_config(hc_post_config, NULL, runAfter, APR_HOOK_LAST);

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1722195&r1=1722194&r2=1722195&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Dec 29 17:42:19 2015
@@ -54,21 +54,22 @@ typedef struct {
     const char   *proxy_auth;      /* Proxy authorization */
 } forward_info;
 
-/* Keep synced with mod_proxy.h! */
-static struct wstat {
+static struct proxy_wstat {
     unsigned int bit;
     char flag;
     const char *name;
-} wstat_tbl[] = {
+} proxy_wstat_tbl[] = {
     {PROXY_WORKER_INITIALIZED,   PROXY_WORKER_INITIALIZED_FLAG,   "Init "},
     {PROXY_WORKER_IGNORE_ERRORS, PROXY_WORKER_IGNORE_ERRORS_FLAG, "Ign "},
     {PROXY_WORKER_DRAIN,         PROXY_WORKER_DRAIN_FLAG,         "Drn "},
+    {PROXY_WORKER_GENERIC,       PROXY_WORKER_GENERIC_FLAG,       "Gen "},
     {PROXY_WORKER_IN_SHUTDOWN,   PROXY_WORKER_IN_SHUTDOWN_FLAG,   "Shut "},
     {PROXY_WORKER_DISABLED,      PROXY_WORKER_DISABLED_FLAG,      "Dis "},
     {PROXY_WORKER_STOPPED,       PROXY_WORKER_STOPPED_FLAG,       "Stop "},
     {PROXY_WORKER_IN_ERROR,      PROXY_WORKER_IN_ERROR_FLAG,      "Err "},
     {PROXY_WORKER_HOT_STANDBY,   PROXY_WORKER_HOT_STANDBY_FLAG,   "Stby "},
     {PROXY_WORKER_FREE,          PROXY_WORKER_FREE_FLAG,          "Free "},
+    {PROXY_WORKER_HC_FAIL,       PROXY_WORKER_HC_FAIL_FLAG,       "HcFl "},
     {0x0, '\0', NULL}
 };
 
@@ -3126,7 +3127,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_set
 {
     unsigned int *status = &w->s->status;
     char flag = toupper(c);
-    struct wstat *pwt = wstat_tbl;
+    struct proxy_wstat *pwt = proxy_wstat_tbl;
     while (pwt->bit) {
         if (flag == pwt->flag) {
             if (set)
@@ -3144,12 +3145,15 @@ PROXY_DECLARE(char *) ap_proxy_parse_wst
 {
     char *ret = "";
     unsigned int status = w->s->status;
-    struct wstat *pwt = wstat_tbl;
+    struct proxy_wstat *pwt = proxy_wstat_tbl;
     while (pwt->bit) {
         if (status & pwt->bit)
             ret = apr_pstrcat(p, ret, pwt->name, NULL);
         pwt++;
     }
+    if (!*ret) {
+        ret = "??? ";
+    }
     if (PROXY_WORKER_IS_USABLE(w))
         ret = apr_pstrcat(p, ret, "Ok ", NULL);
     return ret;



Mime
View raw message