httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1723953 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h mod_proxy_hcheck.c
Date Sun, 10 Jan 2016 19:20:32 GMT
Author: jim
Date: Sun Jan 10 19:20:31 2016
New Revision: 1723953

URL: http://svn.apache.org/viewvc?rev=1723953&view=rev
Log:
Use enums and structs to keep things better organized

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.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=1723953&r1=1723952&r2=1723953&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Sun Jan 10 19:20:31 2016
@@ -75,6 +75,26 @@ enum enctype {
     enc_path, enc_search, enc_user, enc_fpath, enc_parm
 };
 
+typedef enum {
+    NONE, TCP, OPTIONS, HEAD, GET, CPING, PROVIDER, EOT
+} hcmethod_t;
+
+typedef struct {
+    hcmethod_t method;
+    char *name;
+} hcmethods_t;
+
+static hcmethods_t hcmethods[] = {
+        {NONE, "NONE"},
+        {TCP, "TCP"},
+        {OPTIONS, "OPTIONS"},
+        {HEAD, "HEAD"},
+        {GET, "GET"},
+        {CPING, "CPING"},
+        {PROVIDER, "PROVIDER"},
+        {EOT, NULL}
+};
+
 #define BALANCER_PREFIX "balancer://"
 
 #if APR_CHARSET_EBCDIC
@@ -365,7 +385,7 @@ typedef struct {
     char      redirect[PROXY_WORKER_MAX_ROUTE_SIZE];  /* temporary balancing redirection
route */
     char      flusher[PROXY_WORKER_MAX_SCHEME_SIZE];  /* flush provider used by mod_proxy_fdpass
*/
     char      uds_path[PROXY_WORKER_MAX_NAME_SIZE];   /* path to worker's unix domain socket
if applicable */
-    char      hurl[PROXY_WORKER_MAX_ROUTE_SIZE];      /* health check url */
+    char      hcuri[PROXY_WORKER_MAX_ROUTE_SIZE];     /* health check uri */
     int             lbset;      /* load balancer cluster set */
     int             retries;    /* number of retries on this worker */
     int             lbstatus;   /* Current lbstatus */
@@ -375,7 +395,6 @@ typedef struct {
     int             hmax;       /* Hard maximum on the total number of connections */
     int             flush_wait; /* poll wait time in microseconds if flush_auto */
     int             index;      /* shm array index */
-    int             method;     /* method to use for health check */
     int             passes;     /* number of successes for check to pass */
     int             pcount;     /* current count of passes */
     int             fails;      /* number of failures for check to fail */
@@ -386,7 +405,8 @@ typedef struct {
         flush_off,
         flush_on,
         flush_auto
-    } flush_packets;           /* control AJP flushing */
+    } flush_packets;            /* control AJP flushing */
+    hcmethod_t      method;     /* method to use for health check */
     apr_time_t      updated;    /* timestamp of last update */
     apr_time_t      error_time; /* time of the last error */
     apr_interval_time_t ttl;    /* maximum amount of time in seconds a connection

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=1723953&r1=1723952&r2=1723953&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c Sun Jan 10 19:20:31 2016
@@ -19,7 +19,6 @@
 #include "ap_slotmem.h"
 #include "ap_expr.h"
 
-
 module AP_MODULE_DECLARE_DATA proxy_hcheck_module;
 
 #define HCHECK_WATHCHDOG_NAME ("_proxy_hcheck_")
@@ -28,13 +27,9 @@ module AP_MODULE_DECLARE_DATA proxy_hche
 /* The watchdog runs every 5 seconds, which is also the minimal check */
 #define HCHECK_WATHCHDOG_INTERVAL (5)
 
-static char *methods[] = {
-      "NULL", "OPTIONS", "HEAD", "CPING", NULL
-};
-
 typedef struct {
     char *name;
-    int method;
+    hcmethod_t method;
     int passes;
     int fails;
     apr_interval_time_t interval;
@@ -95,7 +90,7 @@ static const char *set_worker_hc_param(a
                     worker->s->interval = template->interval;
                     worker->s->passes = template->passes;
                     worker->s->fails = template->fails;
-                    PROXY_STRNCPY(worker->s->hurl, template->hurl);
+                    PROXY_STRNCPY(worker->s->hcuri, template->hurl);
                 } else {
                     temp->method = template->method;
                     temp->interval = template->interval;
@@ -109,12 +104,13 @@ static const char *set_worker_hc_param(a
         return apr_psprintf(p, "Unknown ProxyHCTemplate name: %s", val);
     }
     else if (!strcasecmp(key, "hcmethod")) {
-        for (ival = 1; methods[ival]; ival++) {
-            if (!ap_casecmpstr(val, methods[ival])) {
+        hcmethods_t *method = hcmethods;
+        for (; method->name; method++) {
+            if (!ap_casecmpstr(val, method->name)) {
                 if (worker) {
-                    worker->s->method = ival;
+                    worker->s->method = method->method;
                 } else {
-                    temp->method = ival;
+                    temp->method = method->method;
                 }
                 return NULL;
             }
@@ -152,11 +148,11 @@ static const char *set_worker_hc_param(a
         }
     }
     else if (!strcasecmp(key, "hcuri")) {
-        if (strlen(val) >= sizeof(worker->s->hurl))
+        if (strlen(val) >= sizeof(worker->s->hcuri))
             return apr_psprintf(p, "Health check uri length must be < %d characters",
-                    (int)sizeof(worker->s->hurl));
+                    (int)sizeof(worker->s->hcuri));
         if (worker) {
-            PROXY_STRNCPY(worker->s->hurl, val);
+            PROXY_STRNCPY(worker->s->hcuri, val);
         } else {
             temp->hurl = apr_pstrdup(p, val);
         }



Mime
View raw message