Commit 4e45e051 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Pull this out as a sep function to allow for full vhosting

adjustment between get and define balancers...

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1207562 13f79535-47bb-0310-9956-ffa450edef68
parent a20d1fc8
Loading
Loading
Loading
Loading
+11 −0
Changes for modules/proxy/mod_proxy.h: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -644,6 +644,17 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
                                                      proxy_server_conf *conf,
                                                      const char *url);

/**
 * Update the balancer's vhost related fields
 * @param p     memory pool used for temporary storage while finding balancer
 * @param balancer  balancer to be updated
 * @param url   url to find vhost info
 * @return      error string or NULL if OK
 */
PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p,
                                               proxy_balancer *balancer,
                                               const char *url);

/**
 * Define and Allocate space for the balancer to proxy configuration
 * @param p      memory pool to allocate balancer from
+21 −7
Changes for modules/proxy/proxy_util.c: 21 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -1316,6 +1316,26 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
    return NULL;
}


PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p,
                                                proxy_balancer *balancer,
                                                const char *url)
{
    apr_uri_t puri;
    if (apr_uri_parse(p, url, &puri) != APR_SUCCESS) {
        return apr_psprintf(p, "unable to parse: %s", url);
    }
    if (puri.path && PROXY_STRNCPY(balancer->s->vpath, puri.path) != APR_SUCCESS) {
        return apr_psprintf(p, "balancer %s front-end virtual-path (%s) too long",
                            balancer->s->name, puri.path);
    }
    if (puri.hostname && PROXY_STRNCPY(balancer->s->vhost, puri.hostname) != APR_SUCCESS) {
        return apr_psprintf(p, "balancer %s front-end vhost name (%s) too long",
                            balancer->s->name, puri.hostname);
    }
    return NULL;
}

PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
                                               proxy_balancer **balancer,
                                               proxy_server_conf *conf,
@@ -1329,7 +1349,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
    proxy_balancer_shared *bshared;
    char *c, *q, *uri = apr_pstrdup(p, url);
    const char *sname;
    apr_uri_t puri;

    /* We should never get here without a valid BALANCER_PREFIX... */

@@ -1344,8 +1363,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
    *balancer = apr_array_push(conf->balancers);
    memset(*balancer, 0, sizeof(proxy_balancer));

    apr_uri_parse(p, alias, &puri);

    /*
     * NOTE: The default method is byrequests, which we assume
     * exists!
@@ -1378,9 +1395,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
    if (PROXY_STRNCPY(bshared->sname, sname) != APR_SUCCESS) {
        return apr_psprintf(p, "balancer safe-name (%s) too long", sname);
    }
    if (PROXY_STRNCPY(bshared->vpath, puri.path) != APR_SUCCESS) {
        return apr_psprintf(p, "balancer front-end virtual-path (%s) too long", puri.path);
    }
    bshared->hash = ap_proxy_hashfunc(bshared->name, PROXY_HASHFUNC_DEFAULT);    
    (*balancer)->hash = bshared->hash;

@@ -1394,7 +1408,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,

    (*balancer)->s = bshared;

    return NULL;
    return ap_proxy_update_balancer(p, *balancer, alias);
}

/*