Commit 910b2327 authored by Mladen Turk's avatar Mladen Turk
Browse files

Add status param option so that current worker

status can be changed via editing httpd.conf instead
just using web page. Seems the ApacheCon is paying of.
Thanks to Sander for pointing that out.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@225751 13f79535-47bb-0310-9956-ffa450edef68
parent 42b45e0c
Loading
Loading
Loading
Loading
+37 −0
Changes for modules/proxy/mod_proxy.c: 37 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -181,6 +181,43 @@ static const char *set_worker_param(apr_pool_t *p,
            return "Redirect length must be < 64 characters";
        worker->redirect = apr_pstrdup(p, val);
    }
    else if (!strcasecmp(key, "status")) {
        const char *v;
        int mode = 1;
        /* Worker status.
         */
        for (v = val; *v; v++) {
            if (*v == '+') {
                mode = 1;
                v++;    
            }
            else if (*v == '-') {
                mode = 0;
                v++;    
            }
            if (*v == 'D' || *v == 'd') {
                if (mode)
                    worker->status |= PROXY_WORKER_DISABLED;
                else
                    worker->status &= ~PROXY_WORKER_DISABLED;                    
            }
            else if (*v == 'S' || *v == 's') {
                if (mode)
                    worker->status |= PROXY_WORKER_STOPPED;
                else
                    worker->status &= ~PROXY_WORKER_STOPPED;                    
            }
            else if (*v == 'E' || *v == 'e') {
                if (mode)
                    worker->status |= PROXY_WORKER_IN_ERROR;
                else
                    worker->status &= ~PROXY_WORKER_IN_ERROR;                    
            }
            else {
                return "Unknow status parameter option";    
            }
        }
    }    
    else {
        return "unknown Worker parameter";
    }
+3 −1
Changes for modules/proxy/mod_proxy.h: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -228,7 +228,8 @@ struct proxy_conn_pool {
#define PROXY_WORKER_IGNORE_ERRORS  0x0002
#define PROXY_WORKER_IN_SHUTDOWN    0x0010
#define PROXY_WORKER_DISABLED       0x0020
#define PROXY_WORKER_IN_ERROR       0x0040
#define PROXY_WORKER_STOPPED        0x0040
#define PROXY_WORKER_IN_ERROR       0x0080

#define PROXY_WORKER_IS_USABLE(f)   (!((f)->s->status & 0x00F0))

@@ -260,6 +261,7 @@ struct proxy_worker {
    const char      *hostname;  /* remote backend address */
    const char      *route;     /* balancing route */
    const char      *redirect;  /* temporary balancing redirection route */
    int             status;     /* temporary worker status */
    apr_port_t      port;
    int             min;        /* Desired minimum number of available connections */
    int             smax;       /* Soft maximum on the total number of connections */
+1 −1
Changes for modules/proxy/proxy_util.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -1620,7 +1620,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
             worker->id, getpid(), worker->hostname);
    }
    if (rv == APR_SUCCESS)
        worker->s->status |= PROXY_WORKER_INITIALIZED;
        worker->s->status |= (worker->status | PROXY_WORKER_INITIALIZED);
    return rv;
}