1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

whitespace

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1058626 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Jagielski
2011-01-13 15:59:10 +00:00
parent fab3678ad3
commit ddebc67a4e
5 changed files with 76 additions and 78 deletions

View File

@@ -985,7 +985,7 @@ static int proxy_handler(request_rec *r)
/* Initialise worker if needed, note the shared area must be initialized by the balancer logic */ /* Initialise worker if needed, note the shared area must be initialized by the balancer logic */
if (balancer) { if (balancer) {
ap_proxy_initialize_worker(worker, r->server, conf->pool); ap_proxy_initialize_worker(worker, r->server, conf->pool);
} }
if (balancer && balancer->max_attempts_set && !max_attempts) if (balancer && balancer->max_attempts_set && !max_attempts)
@@ -1357,7 +1357,7 @@ static const char *
const char *err; const char *err;
err = ap_check_cmd_context(cmd, NOT_IN_DIRECTORY|NOT_IN_FILES); err = ap_check_cmd_context(cmd, NOT_IN_DIRECTORY|NOT_IN_FILES);
if (err) { if (err) {
return err; return err;
} }
@@ -1512,7 +1512,7 @@ static const char * add_pass_reverse(cmd_parms *cmd, void *dconf, const char *f,
const char *err; const char *err;
err = ap_check_cmd_context(cmd, NOT_IN_DIRECTORY|NOT_IN_FILES); err = ap_check_cmd_context(cmd, NOT_IN_DIRECTORY|NOT_IN_FILES);
if (err) { if (err) {
return err; return err;
} }
@@ -2391,7 +2391,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
PROXY_STRNCPY(conf->forward->s->name, "proxy:forward"); PROXY_STRNCPY(conf->forward->s->name, "proxy:forward");
PROXY_STRNCPY(conf->forward->s->hostname, "*"); PROXY_STRNCPY(conf->forward->s->hostname, "*");
PROXY_STRNCPY(conf->forward->s->scheme, "*"); PROXY_STRNCPY(conf->forward->s->scheme, "*");
conf->forward->hash = conf->forward->s->hash = conf->forward->hash = conf->forward->s->hash =
ap_proxy_hashfunc(conf->forward->s->name, PROXY_HASHFUNC_DEFAULT); ap_proxy_hashfunc(conf->forward->s->name, PROXY_HASHFUNC_DEFAULT);
/* Do not disable worker in case of errors */ /* Do not disable worker in case of errors */
conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS; conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
@@ -2404,7 +2404,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
PROXY_STRNCPY(reverse->s->name, "proxy:reverse"); PROXY_STRNCPY(reverse->s->name, "proxy:reverse");
PROXY_STRNCPY(reverse->s->hostname, "*"); PROXY_STRNCPY(reverse->s->hostname, "*");
PROXY_STRNCPY(reverse->s->scheme, "*"); PROXY_STRNCPY(reverse->s->scheme, "*");
reverse->hash = reverse->s->hash = reverse->hash = reverse->s->hash =
ap_proxy_hashfunc(reverse->s->name, PROXY_HASHFUNC_DEFAULT); ap_proxy_hashfunc(reverse->s->name, PROXY_HASHFUNC_DEFAULT);
/* Do not disable worker in case of errors */ /* Do not disable worker in case of errors */
reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS; reverse->s->status |= PROXY_WORKER_IGNORE_ERRORS;

View File

@@ -15,7 +15,7 @@
*/ */
#ifndef MOD_PROXY_H #ifndef MOD_PROXY_H
#define MOD_PROXY_H #define MOD_PROXY_H
/** /**
* @file mod_proxy.h * @file mod_proxy.h
@@ -159,7 +159,7 @@ typedef struct {
} proxy_status; /* Status display options */ } proxy_status; /* Status display options */
apr_sockaddr_t *source_address; apr_sockaddr_t *source_address;
apr_global_mutex_t *mutex; /* global lock (needed??) */ apr_global_mutex_t *mutex; /* global lock (needed??) */
int req_set:1; int req_set:1;
int viaopt_set:1; int viaopt_set:1;
int recv_buffer_size_set:1; int recv_buffer_size_set:1;
@@ -384,7 +384,7 @@ struct proxy_balancer_method {
void *context; /* general purpose storage */ void *context; /* general purpose storage */
apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s); apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s);
apr_status_t (*age)(proxy_balancer *balancer, server_rec *s); apr_status_t (*age)(proxy_balancer *balancer, server_rec *s);
apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s); apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s);
}; };
#define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex) #define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex)
@@ -395,7 +395,7 @@ struct proxy_balancer_method {
/* hooks */ /* hooks */
/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
* PROXY_DECLARE_DATA with appropriate export and import tags for the platform * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
*/ */
#if !defined(WIN32) #if !defined(WIN32)
@@ -423,14 +423,14 @@ struct proxy_balancer_method {
#define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \ #define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \
APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order) APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order)
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r, APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
proxy_worker *worker, proxy_server_conf *conf, char *url, proxy_worker *worker, proxy_server_conf *conf, char *url,
const char *proxyhost, apr_port_t proxyport)) const char *proxyhost, apr_port_t proxyport))
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r, APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
char *url)) char *url))
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
/** /**
* pre request hook. * pre request hook.
@@ -443,7 +443,7 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker, APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
proxy_balancer **balancer, proxy_balancer **balancer,
request_rec *r, request_rec *r,
proxy_server_conf *conf, char **url)) proxy_server_conf *conf, char **url))
/** /**
* post request hook. * post request hook.
* It is called after request for updating runtime balancer status. * It is called after request for updating runtime balancer status.
@@ -528,7 +528,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
const char *url); const char *url);
/** /**
* Define and Allocate space for the worker to proxy configuration * Define and Allocate space for the worker to proxy configuration
* @param p memory pool to allocate worker from * @param p memory pool to allocate worker from
* @param worker the new worker * @param worker the new worker
* @param balancer the balancer that the worker belongs to * @param balancer the balancer that the worker belongs to
* @param conf current proxy server configuration * @param conf current proxy server configuration
@@ -543,7 +543,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
/** /**
* Share a defined proxy worker via shm * Share a defined proxy worker via shm
* @param worker worker to be shared * @param worker worker to be shared
* @param shm location of shared info * @param shm location of shared info
* @param i index into shm * @param i index into shm
* @return APR_SUCCESS or error code * @return APR_SUCCESS or error code
@@ -583,7 +583,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
/** /**
* Define and Allocate space for the balancer to proxy configuration * Define and Allocate space for the balancer to proxy configuration
* @param p memory pool to allocate balancer from * @param p memory pool to allocate balancer from
* @param balancer the new balancer * @param balancer the new balancer
* @param conf current proxy server configuration * @param conf current proxy server configuration
* @param url url containing balancer name * @param url url containing balancer name
@@ -601,7 +601,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
* @param r current request * @param r current request
* @param conf current proxy server configuration * @param conf current proxy server configuration
* @param url request url that balancer can rewrite. * @param url request url that balancer can rewrite.
* @return OK or HTTP_XXX error * @return OK or HTTP_XXX error
* @note It calls balancer pre_request hook if the url starts with balancer:// * @note It calls balancer pre_request hook if the url starts with balancer://
* The balancer then rewrites the url to particular worker, like http://host:port * The balancer then rewrites the url to particular worker, like http://host:port
*/ */
@@ -618,7 +618,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
* @param conf current proxy server configuration * @param conf current proxy server configuration
* @return OK or HTTP_XXX error * @return OK or HTTP_XXX error
* @note Whenever the pre_request is called, the post_request has to be * @note Whenever the pre_request is called, the post_request has to be
* called too. * called too.
*/ */
PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker, PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
proxy_balancer *balancer, proxy_balancer *balancer,
@@ -647,7 +647,7 @@ PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
* @param server_portstr Via headers server port * @param server_portstr Via headers server port
* @param server_portstr_size size of the server_portstr buffer * @param server_portstr_size size of the server_portstr buffer
* @return OK or HTTP_XXX error * @return OK or HTTP_XXX error
*/ */
PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
proxy_server_conf *conf, proxy_server_conf *conf,
proxy_worker *worker, proxy_worker *worker,
@@ -694,7 +694,7 @@ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
* @param s current server record * @param s current server record
* @return OK or HTTP_XXX error * @return OK or HTTP_XXX error
* @note The connection will be closed if conn->close_on_release is set * @note The connection will be closed if conn->close_on_release is set
*/ */
PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function, PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
proxy_conn_rec *conn, proxy_conn_rec *conn,
server_rec *s); server_rec *s);
@@ -707,7 +707,7 @@ PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
* @return OK or HTTP_XXX error * @return OK or HTTP_XXX error
* @note In case the socket already exists for conn, just check the link * @note In case the socket already exists for conn, just check the link
* status. * status.
*/ */
PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
proxy_conn_rec *conn, proxy_conn_rec *conn,
proxy_worker *worker, proxy_worker *worker,

View File

@@ -35,18 +35,18 @@ static char balancer_nonce[APR_UUID_FORMATTED_LENGTH + 1];
* Register our mutex type before the config is read so we * Register our mutex type before the config is read so we
* can adjust the mutex settings using the Mutex directive. * can adjust the mutex settings using the Mutex directive.
*/ */
static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog, static int balancer_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp) apr_pool_t *ptemp)
{ {
apr_status_t rv; apr_status_t rv;
rv = ap_mutex_register(pconf, balancer_mutex_type, NULL, rv = ap_mutex_register(pconf, balancer_mutex_type, NULL,
APR_LOCK_DEFAULT, 0); APR_LOCK_DEFAULT, 0);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
return rv; return rv;
} }
return OK; return OK;
} }
@@ -207,7 +207,7 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer,
int i; int i;
int checking_standby; int checking_standby;
int checked_standby; int checked_standby;
proxy_worker **workers; proxy_worker **workers;
checking_standby = checked_standby = 0; checking_standby = checked_standby = 0;
@@ -475,7 +475,7 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
/* Step 3: force recovery */ /* Step 3: force recovery */
force_recovery(*balancer, r->server); force_recovery(*balancer, r->server);
/* Step 3.5: Update member list for the balancer */ /* Step 3.5: Update member list for the balancer */
/* TODO: Implement as provider! */ /* TODO: Implement as provider! */
/* proxy_update_members(balancer, r, conf); */ /* proxy_update_members(balancer, r, conf); */
@@ -715,8 +715,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
* the process. */ * the process. */
apr_uuid_get(&uuid); apr_uuid_get(&uuid);
apr_uuid_format(balancer_nonce, &uuid); apr_uuid_format(balancer_nonce, &uuid);
/* /*
* Get worker slotmem setup * Get worker slotmem setup
*/ */
@@ -736,14 +735,14 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
proxy_balancer *balancer; proxy_balancer *balancer;
sconf = s->module_config; sconf = s->module_config;
conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module); conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
/* Initialize shared scoreboard data */ /* Initialize shared scoreboard data */
balancer = (proxy_balancer *)conf->balancers->elts; balancer = (proxy_balancer *)conf->balancers->elts;
for (i = 0; i < conf->balancers->nelts; i++, balancer++) { for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
proxy_worker **workers; proxy_worker **workers;
proxy_worker *worker; proxy_worker *worker;
ap_slotmem_instance_t *new = NULL; ap_slotmem_instance_t *new = NULL;
balancer->max_workers = balancer->workers->nelts + balancer->growth; balancer->max_workers = balancer->workers->nelts + balancer->growth;
balancer->sname = ap_md5(pconf, (const unsigned char *)balancer->name); balancer->sname = ap_md5(pconf, (const unsigned char *)balancer->name);
@@ -756,10 +755,10 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
balancer->sname); balancer->sname);
return HTTP_INTERNAL_SERVER_ERROR; return HTTP_INTERNAL_SERVER_ERROR;
} }
apr_pool_cleanup_register(pconf, (void *)s, lock_remove, apr_pool_cleanup_register(pconf, (void *)s, lock_remove,
apr_pool_cleanup_null); apr_pool_cleanup_null);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing create: %s (%s), %d, %d", ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing create: %s (%s), %d, %d",
balancer->name, balancer->sname, balancer->name, balancer->sname,
(int)sizeof(proxy_worker_shared), (int)sizeof(proxy_worker_shared),
@@ -782,7 +781,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
if ((rv = storage->grab(balancer->slot, &index)) != APR_SUCCESS) { if ((rv = storage->grab(balancer->slot, &index)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "slotmem_grab failed"); ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "slotmem_grab failed");
return !OK; return !OK;
} }
if ((rv = storage->dptr(balancer->slot, index, (void *)&shm)) != APR_SUCCESS) { if ((rv = storage->dptr(balancer->slot, index, (void *)&shm)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "slotmem_dptr failed"); ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "slotmem_dptr failed");
@@ -796,7 +795,7 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog,
} }
s = s->next; s = s->next;
} }
return OK; return OK;
} }
@@ -849,11 +848,11 @@ static int balancer_handler(request_rec *r)
return HTTP_BAD_REQUEST; return HTTP_BAD_REQUEST;
} }
} }
/* Check that the supplied nonce matches this server's nonce; /* Check that the supplied nonce matches this server's nonce;
* otherwise ignore all parameters, to prevent a CSRF attack. */ * otherwise ignore all parameters, to prevent a CSRF attack. */
if (*balancer_nonce && if (*balancer_nonce &&
((name = apr_table_get(params, "nonce")) == NULL ((name = apr_table_get(params, "nonce")) == NULL
|| strcmp(balancer_nonce, name) != 0)) { || strcmp(balancer_nonce, name) != 0)) {
apr_table_clear(params); apr_table_clear(params);
} }
@@ -985,7 +984,7 @@ static int balancer_handler(request_rec *r)
ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=", ap_rvputs(r, "<tr>\n<td><a href=\"", r->uri, "?b=",
balancer->name + sizeof(BALANCER_PREFIX) - 1, "&w=", balancer->name + sizeof(BALANCER_PREFIX) - 1, "&w=",
ap_escape_uri(r->pool, worker->s->name), ap_escape_uri(r->pool, worker->s->name),
"&nonce=", balancer_nonce, "&nonce=", balancer_nonce,
"\">", NULL); "\">", NULL);
ap_rvputs(r, worker->s->name, "</a></td>", NULL); ap_rvputs(r, worker->s->name, "</a></td>", NULL);
ap_rvputs(r, "<td>", ap_escape_html(r->pool, worker->s->route), ap_rvputs(r, "<td>", ap_escape_html(r->pool, worker->s->route),
@@ -1049,7 +1048,7 @@ static int balancer_handler(request_rec *r)
ap_rvputs(r, "<input type=hidden name=\"b\" ", NULL); ap_rvputs(r, "<input type=hidden name=\"b\" ", NULL);
ap_rvputs(r, "value=\"", bsel->name + sizeof(BALANCER_PREFIX) - 1, ap_rvputs(r, "value=\"", bsel->name + sizeof(BALANCER_PREFIX) - 1,
"\">\n", NULL); "\">\n", NULL);
ap_rvputs(r, "<input type=hidden name=\"nonce\" value=\"", ap_rvputs(r, "<input type=hidden name=\"nonce\" value=\"",
balancer_nonce, "\">\n", NULL); balancer_nonce, "\">\n", NULL);
ap_rvputs(r, "</form>\n", NULL); ap_rvputs(r, "</form>\n", NULL);
ap_rputs("<hr />\n", r); ap_rputs("<hr />\n", r);
@@ -1068,7 +1067,7 @@ static void balancer_child_init(apr_pool_t *p, server_rec *s)
void *sconf = s->module_config; void *sconf = s->module_config;
proxy_server_conf *conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module); proxy_server_conf *conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
apr_status_t rv; apr_status_t rv;
balancer = (proxy_balancer *)conf->balancers->elts; balancer = (proxy_balancer *)conf->balancers->elts;
for (i = 0; i < conf->balancers->nelts; i++) { for (i = 0; i < conf->balancers->nelts; i++) {
apr_size_t size; apr_size_t size;
@@ -1086,15 +1085,15 @@ static void balancer_child_init(apr_pool_t *p, server_rec *s)
} }
/* Re-open the mutex for the child. */ /* Re-open the mutex for the child. */
rv = apr_global_mutex_child_init(&(balancer->mutex), rv = apr_global_mutex_child_init(&(balancer->mutex),
apr_global_mutex_lockfile(balancer->mutex), apr_global_mutex_lockfile(balancer->mutex),
p); p);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
"Failed to reopen mutex %: %s in child", "Failed to reopen mutex %: %s in child",
balancer->name, balancer_mutex_type); balancer->name, balancer_mutex_type);
exit(1); /* Ugly, but what else? */ exit(1); /* Ugly, but what else? */
} }
/* now attach */ /* now attach */
storage->attach(&(balancer->slot), balancer->sname, &size, &num, p); storage->attach(&(balancer->slot), balancer->sname, &size, &num, p);

View File

@@ -1121,7 +1121,7 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
/* urlpart (l3) assuredly starts with its own '/' */ /* urlpart (l3) assuredly starts with its own '/' */
if ((*worker)->s->name[l2 - 1] == '/') if ((*worker)->s->name[l2 - 1] == '/')
--l2; --l2;
if (l1 >= l2 + l3 if (l1 >= l2 + l3
&& strncasecmp((*worker)->s->name, url, l2) == 0 && strncasecmp((*worker)->s->name, url, l2) == 0
&& strncmp(urlpart, url + l2, l3) == 0) { && strncmp(urlpart, url + l2, l3) == 0) {
u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3], u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3],
@@ -1306,7 +1306,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
proxy_balancer *balancer; proxy_balancer *balancer;
char *c, *uri = apr_pstrdup(p, url); char *c, *uri = apr_pstrdup(p, url);
int i; int i;
c = strchr(uri, ':'); c = strchr(uri, ':');
if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') { if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
return NULL; return NULL;
@@ -1341,7 +1341,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
/* remove path from uri */ /* remove path from uri */
if ((q = strchr(c + 3, '/'))) if ((q = strchr(c + 3, '/')))
*q = '\0'; *q = '\0';
ap_str_tolower(uri); ap_str_tolower(uri);
*balancer = apr_array_push(conf->balancers); *balancer = apr_array_push(conf->balancers);
memset(*balancer, 0, sizeof(proxy_balancer)); memset(*balancer, 0, sizeof(proxy_balancer));
@@ -1575,15 +1575,15 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
const char *c; const char *c;
char *url_copy; char *url_copy;
int i; int i;
c = ap_strchr_c(url, ':'); c = ap_strchr_c(url, ':');
if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') { if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
return NULL; return NULL;
} }
url_copy = apr_pstrdup(p, url); url_copy = apr_pstrdup(p, url);
url_length = strlen(url); url_length = strlen(url);
/* /*
* We need to find the start of the path and * We need to find the start of the path and
* therefore we know the length of the scheme://hostname/ * therefore we know the length of the scheme://hostname/
@@ -1609,7 +1609,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
* a minimum matching of length min_match such that * a minimum matching of length min_match such that
* scheme://hostname[:port] matches between worker and url. * scheme://hostname[:port] matches between worker and url.
*/ */
if (balancer) { if (balancer) {
proxy_worker **workers = (proxy_worker **)balancer->workers->elts; proxy_worker **workers = (proxy_worker **)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, workers++) { for (i = 0; i < balancer->workers->nelts; i++, workers++) {
@@ -1621,7 +1621,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
max_worker = worker; max_worker = worker;
max_match = worker_name_length; max_match = worker_name_length;
} }
} }
} else { } else {
worker = (proxy_worker *)conf->workers->elts; worker = (proxy_worker *)conf->workers->elts;
@@ -1635,7 +1635,7 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
} }
} }
} }
return max_worker; return max_worker;
} }
@@ -1655,22 +1655,22 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
int rv; int rv;
apr_uri_t uri; apr_uri_t uri;
proxy_worker_shared *wstatus; proxy_worker_shared *wstatus;
rv = apr_uri_parse(p, url, &uri); rv = apr_uri_parse(p, url, &uri);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
return "Unable to parse URL"; return "Unable to parse URL";
} }
if (!uri.hostname || !uri.scheme) { if (!uri.hostname || !uri.scheme) {
return "URL must be absolute!"; return "URL must be absolute!";
} }
ap_str_tolower(uri.hostname); ap_str_tolower(uri.hostname);
ap_str_tolower(uri.scheme); ap_str_tolower(uri.scheme);
/* /*
* Workers can be associated w/ balancers or on their * Workers can be associated w/ balancers or on their
* own; ie: the generic reverse-proxy or a worker * own; ie: the generic reverse-proxy or a worker
* in a simple ProxyPass statement. eg: * in a simple ProxyPass statement. eg:
* *
* ProxyPass / http://www.example.com * ProxyPass / http://www.example.com
* *
@@ -1687,7 +1687,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
/* we need to allocate space here */ /* we need to allocate space here */
*worker = apr_palloc(p, sizeof(proxy_worker)); *worker = apr_palloc(p, sizeof(proxy_worker));
} }
memset(*worker, 0, sizeof(proxy_worker)); memset(*worker, 0, sizeof(proxy_worker));
/* right here we just want to tuck away the worker info. /* right here we just want to tuck away the worker info.
* if called during config, we don't have shm setup yet, * if called during config, we don't have shm setup yet,
@@ -1698,8 +1698,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
wstatus = apr_palloc(p, sizeof(proxy_worker_shared)); wstatus = apr_palloc(p, sizeof(proxy_worker_shared));
#endif #endif
memset(wstatus, 0, sizeof(proxy_worker_shared)); memset(wstatus, 0, sizeof(proxy_worker_shared));
PROXY_STRNCPY(wstatus->name, apr_uri_unparse(p, &uri, APR_URI_UNP_REVEALPASSWORD)); PROXY_STRNCPY(wstatus->name, apr_uri_unparse(p, &uri, APR_URI_UNP_REVEALPASSWORD));
PROXY_STRNCPY(wstatus->scheme, uri.scheme); PROXY_STRNCPY(wstatus->scheme, uri.scheme);
PROXY_STRNCPY(wstatus->hostname, uri.hostname); PROXY_STRNCPY(wstatus->hostname, uri.hostname);
@@ -1708,14 +1707,14 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
wstatus->flush_wait = PROXY_FLUSH_WAIT; wstatus->flush_wait = PROXY_FLUSH_WAIT;
wstatus->smax = -1; wstatus->smax = -1;
wstatus->hash = ap_proxy_hashfunc(wstatus->name, PROXY_HASHFUNC_DEFAULT); wstatus->hash = ap_proxy_hashfunc(wstatus->name, PROXY_HASHFUNC_DEFAULT);
(*worker)->hash = wstatus->hash; (*worker)->hash = wstatus->hash;
(*worker)->context = NULL; (*worker)->context = NULL;
(*worker)->cp = NULL; (*worker)->cp = NULL;
(*worker)->mutex = NULL; (*worker)->mutex = NULL;
(*worker)->balancer = balancer; (*worker)->balancer = balancer;
(*worker)->s = wstatus; (*worker)->s = wstatus;
return NULL; return NULL;
} }
@@ -1784,7 +1783,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
/* What if local is init'ed and shm isn't?? Even possible? */ /* What if local is init'ed and shm isn't?? Even possible? */
if (worker->local_status & PROXY_WORKER_INITIALIZED) { if (worker->local_status & PROXY_WORKER_INITIALIZED) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"worker %s local already initialized", worker->s->name); "worker %s local already initialized", worker->s->name);
} }
else { else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
@@ -1796,7 +1795,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
"can not create connection pool"); "can not create connection pool");
return APR_EGENERAL; return APR_EGENERAL;
} }
if (worker->mutex == NULL) { if (worker->mutex == NULL) {
rv = apr_thread_mutex_create(&(worker->mutex), APR_THREAD_MUTEX_DEFAULT, p); rv = apr_thread_mutex_create(&(worker->mutex), APR_THREAD_MUTEX_DEFAULT, p);
@@ -1878,7 +1877,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
proxy_server_conf *conf, char **url) proxy_server_conf *conf, char **url)
{ {
int access_status; int access_status;
access_status = proxy_run_pre_request(worker, balancer, r, conf, url); access_status = proxy_run_pre_request(worker, balancer, r, conf, url);
if (access_status == DECLINED && *balancer == NULL) { if (access_status == DECLINED && *balancer == NULL) {
*worker = ap_proxy_get_worker(r->pool, NULL, conf, *url); *worker = ap_proxy_get_worker(r->pool, NULL, conf, *url);
@@ -1886,7 +1885,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
"proxy: %s: found worker %s for %s", "proxy: %s: found worker %s for %s",
(*worker)->s->scheme, (*worker)->s->name, *url); (*worker)->s->scheme, (*worker)->s->name, *url);
*balancer = NULL; *balancer = NULL;
access_status = OK; access_status = OK;
} }
@@ -1946,7 +1945,7 @@ PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
/* TODO: recycle direct worker */ /* TODO: recycle direct worker */
} }
} }
return access_status; return access_status;
} }
@@ -1961,7 +1960,7 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
apr_status_t rv; apr_status_t rv;
int connected = 0; int connected = 0;
int loglevel; int loglevel;
while (backend_addr && !connected) { while (backend_addr && !connected) {
if ((rv = apr_socket_create(newsock, backend_addr->family, if ((rv = apr_socket_create(newsock, backend_addr->family,
SOCK_STREAM, 0, r->pool)) != APR_SUCCESS) { SOCK_STREAM, 0, r->pool)) != APR_SUCCESS) {
@@ -1979,7 +1978,7 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
backend_addr = backend_addr->next; backend_addr = backend_addr->next;
continue; continue;
} }
if (conf->recv_buffer_size > 0 && if (conf->recv_buffer_size > 0 &&
(rv = apr_socket_opt_set(*newsock, APR_SO_RCVBUF, (rv = apr_socket_opt_set(*newsock, APR_SO_RCVBUF,
conf->recv_buffer_size))) { conf->recv_buffer_size))) {
@@ -1987,14 +1986,14 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
"apr_socket_opt_set(SO_RCVBUF): Failed to set " "apr_socket_opt_set(SO_RCVBUF): Failed to set "
"ProxyReceiveBufferSize, using default"); "ProxyReceiveBufferSize, using default");
} }
rv = apr_socket_opt_set(*newsock, APR_TCP_NODELAY, 1); rv = apr_socket_opt_set(*newsock, APR_TCP_NODELAY, 1);
if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) { if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"apr_socket_opt_set(APR_TCP_NODELAY): " "apr_socket_opt_set(APR_TCP_NODELAY): "
"Failed to set"); "Failed to set");
} }
/* Set a timeout on the socket */ /* Set a timeout on the socket */
if (conf->timeout_set) { if (conf->timeout_set) {
apr_socket_timeout_set(*newsock, conf->timeout); apr_socket_timeout_set(*newsock, conf->timeout);
@@ -2002,11 +2001,11 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
else { else {
apr_socket_timeout_set(*newsock, r->server->timeout); apr_socket_timeout_set(*newsock, r->server->timeout);
} }
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
"proxy: %s: fam %d socket created to connect to %s", "proxy: %s: fam %d socket created to connect to %s",
proxy_function, backend_addr->family, backend_name); proxy_function, backend_addr->family, backend_name);
if (conf->source_address) { if (conf->source_address) {
rv = apr_socket_bind(*newsock, conf->source_address); rv = apr_socket_bind(*newsock, conf->source_address);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
@@ -2015,10 +2014,10 @@ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **newsock,
proxy_function); proxy_function);
} }
} }
/* make the connection out of the socket */ /* make the connection out of the socket */
rv = apr_socket_connect(*newsock, backend_addr); rv = apr_socket_connect(*newsock, backend_addr);
/* if an error occurred, loop round and try again */ /* if an error occurred, loop round and try again */
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
apr_socket_close(*newsock); apr_socket_close(*newsock);
@@ -2154,7 +2153,7 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
* *
* TODO: Handle this much better... * TODO: Handle this much better...
*/ */
if (!conn->hostname || !worker->s->is_address_reusable || if (!conn->hostname || !worker->s->is_address_reusable ||
worker->s->disablereuse || worker->s->disablereuse ||
(r->connection->keepalives && (r->connection->keepalives &&
(r->proxyreq == PROXYREQ_PROXY || r->proxyreq == PROXYREQ_REVERSE) && (r->proxyreq == PROXYREQ_PROXY || r->proxyreq == PROXYREQ_REVERSE) &&
@@ -2519,7 +2518,7 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
rv = apr_socket_bind(newsock, local_addr); rv = apr_socket_bind(newsock, local_addr);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"proxy: %s: failed to bind socket to local address", "proxy: %s: failed to bind socket to local address",
proxy_function); proxy_function);
} }
} }

View File

@@ -536,7 +536,7 @@ AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status
{ {
if (!sbh) if (!sbh)
return -1; return -1;
return update_child_status_internal(sbh->child_num, sbh->thread_num, return update_child_status_internal(sbh->child_num, sbh->thread_num,
status, c, NULL); status, c, NULL);
} }