]> granicus.if.org Git - apache/commitdiff
finish looping logic... place-holder for actual checking
authorJim Jagielski <jim@apache.org>
Tue, 29 Dec 2015 19:40:46 +0000 (19:40 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 29 Dec 2015 19:40:46 +0000 (19:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1722229 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy_hcheck.c

index b7f628f7d30106d037c326ab6c46ddcba01794d1..0a6bf83ae7616df9c11279c5bda5827dcda8c476 100644 (file)
@@ -2678,7 +2678,6 @@ static int proxy_post_config(apr_pool_t *pconf, apr_pool_t *plog,
     proxy_ssl_disable = APR_RETRIEVE_OPTIONAL_FN(ssl_engine_disable);
     proxy_is_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
     proxy_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
-    set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
     ap_proxy_strmatch_path = apr_strmatch_precompile(pconf, "path=", 0);
     ap_proxy_strmatch_domain = apr_strmatch_precompile(pconf, "domain=", 0);
 
@@ -2889,6 +2888,7 @@ static int proxy_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                       APR_HOOK_MIDDLE);
     /* Reset workers count on gracefull restart */
     proxy_lb_workers = 0;
+    set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
     return OK;
 }
 static void register_hooks(apr_pool_t *p)
index 2e11743e6776365a4d62e0a12ebda9dd62d8320a..a9b39fc84700b9c0ac3f9036303e39473920d011 100644 (file)
@@ -45,9 +45,9 @@ static apr_array_header_t *templates = NULL;
 static ap_watchdog_t *watchdog;
 
 /*
- * This is not as clean as it should be, because we are using
- * the same to both update the actual worker as well as verifying
- * and populating the health check 'template' as well.
+ * This serves double duty by not only validating (and creating)
+ * the health-check template, but also ties into set_worker_param()
+ * which does the actual setting of worker params in shm.
  */
 static const char *set_worker_hc_param(apr_pool_t *p,
                                     proxy_worker *worker,
@@ -171,33 +171,60 @@ static const char *set_hcheck(cmd_parms *cmd, void *dummy, const char *arg)
     return NULL;
 }
 
+static void hc_check(apr_pool_t *p, server_rec *s, apr_time_t now,
+                     proxy_worker *worker)
+{
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO()
+                 "Health check (%s).", worker->s->name);
+    return;
+}
+
 static apr_status_t hc_watchdog_callback(int state, void *data,
                                          apr_pool_t *pool)
 {
     apr_status_t rv = APR_SUCCESS;
-    apr_time_t cur, now;
-
-
+    apr_time_t now = apr_time_sec(apr_time_now());
+    proxy_balancer *balancer;
+    server_rec *s = (server_rec *)data;
+    proxy_server_conf *conf;
+    apr_pool_t *p;
     switch (state) {
         case AP_WATCHDOG_STATE_STARTING:
-            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO()
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO()
                          "%s watchdog started.",
                          HCHECK_WATHCHDOG_NAME);
-        break;
+            break;
+
         case AP_WATCHDOG_STATE_RUNNING:
-            cur = now = apr_time_sec(apr_time_now());
-            /*
-            while ((now - cur) < apr_time_sec(ctx->interval)) {
-                break;
+            /* loop thru all workers */
+            apr_pool_create(&p, pool);
+            while (s) {
+                int i;
+                conf = (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
+                balancer = (proxy_balancer *)conf->balancers->elts;
+                for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
+                    int n;
+                    proxy_worker **workers;
+                    proxy_worker *worker;
+                    workers = (proxy_worker **)balancer->workers->elts;
+                    for (n = 0; n < balancer->workers->nelts; n++) {
+                        worker = *workers;
+                        if (worker->s->method && (now > worker->s->updated + worker->s->interval)) {
+                            hc_check(p, s, now, worker);
+                        }
+                        workers++;
+                    }
+                }
+                s = s->next;
             }
-             */
-        break;
+            apr_pool_destroy(p);
+            break;
+
         case AP_WATCHDOG_STATE_STOPPING:
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO()
                          "stopping %s watchdog.",
                          HCHECK_WATHCHDOG_NAME);
-
-        break;
+            break;
     }
     return rv;
 }
@@ -240,7 +267,7 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog,
     }
     rv = hc_watchdog_register_callback(watchdog,
             apr_time_from_sec(HCHECK_WATHCHDOG_INTERVAL),
-            NULL,
+            s,
             hc_watchdog_callback);
     if (rv) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO()