Commit 5a0186d0 authored by Jean-Frederic Clere's avatar Jean-Frederic Clere
Browse files

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
parent cee4c744
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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;
}
+1 −0
Original line number Diff line number Diff line
@@ -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 */
+26 −12
Original line number Diff line number Diff line
@@ -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,16 +195,12 @@ 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)
            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)) )
@@ -225,10 +232,9 @@ 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)) {
@@ -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
+0 −1
Original line number Diff line number Diff line
@@ -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;
};