]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Move health in proxy_worker_stat otherwise testing it in
authorJean-Frederic Clere <jfclere@apache.org>
Thu, 3 Aug 2006 19:31:12 +0000 (19:31 +0000)
committerJean-Frederic Clere <jfclere@apache.org>
Thu, 3 Aug 2006 19:31:12 +0000 (19:31 +0000)
httpd is too complex.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-proxy-scoreboard@428492 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/health_checker_util.c
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_balancer.c
modules/proxy/mod_proxy_health_checker.h

index b4488590ea856fdebaaf3f66221c0a91db8a2293..1c0c3b23076476a46f23272f95a36dc7202eee56 100644 (file)
@@ -204,7 +204,7 @@ static apr_status_t add_entry(proxy_worker *worker, const char *balancer_name, i
     workerconf->keepalive_set = worker->keepalive_set;
     workerconf->flush_packets = worker->flush_packets;
     workerconf->flush_wait = worker->flush_wait;
-    workerconf->health = 0;
+    workerconf->httpstatus.health = HEALTH_UNKNOWN;
     workerconf->used = 1;
     return APR_SUCCESS;
 }
@@ -224,7 +224,7 @@ static apr_status_t get_health(int id, int *health)
     rv = checkstorage->ap_slotmem_mem(myscore, id, (void *) &workerconf);
     if (rv != APR_SUCCESS)
         return rv;
-    *health = workerconf->health;
+    *health = workerconf->httpstatus.health;
     return APR_SUCCESS;
 }
 /* set the health of the entry: for the health-checker */
@@ -238,7 +238,7 @@ static apr_status_t set_health(int id, int value)
     rv = checkstorage->ap_slotmem_mem(myscore, id, (void *) &workerconf);
     if (rv != APR_SUCCESS)
         return rv;
-    workerconf->health = value;
+    workerconf->httpstatus.health = value;
     workerconf->time_checked = apr_time_now();
     return APR_SUCCESS;
 }
@@ -342,9 +342,9 @@ static apr_status_t check_entryhealth(int id, apr_pool_t *pool) {
         return APR_SUCCESS;
     rv = test_backend(workerconf->scheme, workerconf->hostname, workerconf->port, pool);
     if (rv != APR_SUCCESS)
-        workerconf->health = HEALTH_NO;
+        workerconf->httpstatus.health = HEALTH_NO;
     else
-        workerconf->health = HEALTH_OK;
+        workerconf->httpstatus.health = HEALTH_OK;
     workerconf->time_checked = apr_time_now();
     return rv;
 }
index be2bbc97355838f4e77cd9b0a80add3c3fe3210a..713ea82c573be7646c5d797bf0aefed319e20de1 100644 (file)
@@ -285,6 +285,7 @@ typedef struct {
     int             retries;    /* number of retries on this worker */
     int             lbstatus;   /* Current lbstatus */
     int             lbfactor;   /* dynamic lbfactor */
+    int             health;     /* result of the heathchecker */
     apr_off_t       transferred;/* Number of bytes transferred to remote */
     apr_off_t       read;       /* Number of bytes read from remote */
     apr_size_t      elected;    /* Number of times the worker was elected */
index c23bdc8eeb9757714191daf2afccf1568b8a3428..b884e2ce0dbe9495c1bf0d610352b01a9c6861c3 100644 (file)
@@ -175,6 +175,17 @@ static char *get_cookie_param(request_rec *r, const char *name)
     return NULL;
 }
 
+static ap_proxy_close_worker(proxy_worker *worker, request_rec *r)
+{
+    /* XXX: Only prefork mpm's ??? */
+    ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+             "ap_proxy_close_worker: id %d name %s %d", worker->id, worker->name, worker->cp->conn);
+    if (worker->cp->conn) {
+        worker->cp->conn->close = 1;
+        worker->cp->conn->close_on_recycle = 1;
+        ap_proxy_release_connection("Any", worker->cp->conn, r->server);
+    }
+}
 /* Find the worker that has the 'route' defined
  */
 static proxy_worker *find_route_worker(proxy_balancer *balancer,
@@ -184,17 +195,13 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
     int checking_standby = 0;
     int checked_standby = 0;
     proxy_worker *worker;
-    const health_worker_method *worker_storage;
-    worker_storage = ap_lookup_provider(PROXY_CKMETHOD, "default", "0");
     
     while (!checked_standby) {
         worker = (proxy_worker *)balancer->workers->elts;
         for (i = 0; i < balancer->workers->nelts; i++, worker++) {
-            if (worker_storage) {
-                int health;
-                worker_storage->get_health(worker->id, &health);
-                if (health != HEALTH_OK)
-                    continue;
+            if (worker->s->health == HEALTH_NO) {
+                ap_proxy_close_worker(worker, r);
+                continue;
             }
             if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
                 continue;
@@ -225,12 +232,11 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
                             proxy_worker *rworker = NULL;
                             rworker = find_route_worker(balancer, worker->s->redirect, r);
                             /* Check if the redirect worker is usable */
-                            if (rworker && worker_storage) {
-                                int health;
-                                worker_storage->get_health(worker->id, &health);
-                                if (health != HEALTH_OK)
+                            if (rworker)
+                                if (rworker->s->health == HEALTH_NO) {
+                                    ap_proxy_close_worker(rworker, r);
                                     continue;
-                            }
+                                }
                             if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) {
                                 /*
                                  * If the worker is in error state run
@@ -892,6 +898,10 @@ static proxy_worker *find_best_byrequests(proxy_balancer *balancer,
     while (!mycandidate && !checked_standby) {
         worker = (proxy_worker *)balancer->workers->elts;
         for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+            if (worker->s->health == HEALTH_NO) {
+                ap_proxy_close_worker(worker, r);
+                continue;
+            }
             if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
                 continue;
             /* If the worker is in error state run
@@ -959,6 +969,10 @@ static proxy_worker *find_best_bytraffic(proxy_balancer *balancer,
     while (!mycandidate && !checked_standby) {
         worker = (proxy_worker *)balancer->workers->elts;
         for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+            if (worker->s->health == HEALTH_NO) {
+                ap_proxy_close_worker(worker, r);
+                continue;
+            }
             if ( (checking_standby ? !PROXY_WORKER_IS_STANDBY(worker) : PROXY_WORKER_IS_STANDBY(worker)) )
                 continue;
             /* If the worker is in error state run
index 3fc109fd1ab6610eb4004264ee4fd6180657dca5..cd07b51fbb6ffb807eb55cd5855cd488d4990b52 100644 (file)
@@ -96,7 +96,6 @@ struct proxy_worker_conf {
     int                 is_address_reusable;
     int                 flush_packets;
     int                 flush_wait;  /* poll wait time in microseconds if flush_auto */
-    int                 health;
     int                 used;  /* 1 : valid entry 2 : remove 0 : free slot */
     apr_time_t          time_checked;
 };