diff options
author | Jean-Frederic Clere <jfclere@apache.org> | 2006-08-03 19:31:12 +0000 |
---|---|---|
committer | Jean-Frederic Clere <jfclere@apache.org> | 2006-08-03 19:31:12 +0000 |
commit | abcc1807109f5742219691caab0d659238b7341c (patch) | |
tree | b7aff2639cd4d6fe39447854c1dfe01dc8346807 | |
parent | 26d5e1681b9d234c1a5cd92fca81eb1e90461edb (diff) | |
download | httpd-abcc1807109f5742219691caab0d659238b7341c.tar.gz |
Move health in proxy_worker_stat otherwise testing it in
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
-rw-r--r-- | modules/proxy/health_checker_util.c | 10 | ||||
-rw-r--r-- | modules/proxy/mod_proxy.h | 1 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_balancer.c | 38 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_health_checker.h | 1 |
4 files changed, 32 insertions, 18 deletions
diff --git a/modules/proxy/health_checker_util.c b/modules/proxy/health_checker_util.c index b4488590ea..1c0c3b2307 100644 --- a/modules/proxy/health_checker_util.c +++ b/modules/proxy/health_checker_util.c @@ -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; } diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index be2bbc9735..713ea82c57 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -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 */ diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index c23bdc8eeb..b884e2ce0d 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -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 diff --git a/modules/proxy/mod_proxy_health_checker.h b/modules/proxy/mod_proxy_health_checker.h index 3fc109fd1a..cd07b51fbb 100644 --- a/modules/proxy/mod_proxy_health_checker.h +++ b/modules/proxy/mod_proxy_health_checker.h @@ -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; }; |