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

Move the lbmethod to also allow it to be adjusted runtime

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1065750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Jagielski
2011-01-31 20:29:01 +00:00
parent 7b07c3822e
commit 177e4e5f86
4 changed files with 10 additions and 10 deletions

View File

@@ -363,7 +363,7 @@ static const char *set_balancer_param(proxy_server_conf *conf,
proxy_balancer_method *provider; proxy_balancer_method *provider;
provider = ap_lookup_provider(PROXY_LBMETHOD, val, "0"); provider = ap_lookup_provider(PROXY_LBMETHOD, val, "0");
if (provider) { if (provider) {
balancer->lbmethod = provider; balancer->s->lbmethod = provider;
return NULL; return NULL;
} }
return "unknown lbmethod"; return "unknown lbmethod";
@@ -2348,7 +2348,7 @@ static int proxy_status_hook(request_rec *r, int flags)
ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>", ap_rprintf(r, "</td><td>%" APR_TIME_T_FMT "</td>",
apr_time_sec(balancer->s->timeout)); apr_time_sec(balancer->s->timeout));
ap_rprintf(r, "<td>%s</td>\n", ap_rprintf(r, "<td>%s</td>\n",
balancer->lbmethod->name); balancer->s->lbmethod->name);
ap_rputs("</table>\n", r); ap_rputs("</table>\n", r);
ap_rputs("\n\n<table border=\"0\"><tr>" ap_rputs("\n\n<table border=\"0\"><tr>"
"<th>Sch</th><th>Host</th><th>Stat</th>" "<th>Sch</th><th>Host</th><th>Stat</th>"

View File

@@ -368,6 +368,7 @@ typedef struct {
char nonce[APR_UUID_FORMATTED_LENGTH + 1]; char nonce[APR_UUID_FORMATTED_LENGTH + 1];
apr_interval_time_t timeout; /* Timeout for waiting on free connection */ apr_interval_time_t timeout; /* Timeout for waiting on free connection */
apr_time_t updated; /* timestamp of last update */ apr_time_t updated; /* timestamp of last update */
proxy_balancer_method *lbmethod;
int max_attempts; /* Number of attempts before failing */ int max_attempts; /* Number of attempts before failing */
int index; /* shm array index */ int index; /* shm array index */
int sticky_force:1; /* Disable failover for sticky sessions */ int sticky_force:1; /* Disable failover for sticky sessions */
@@ -382,7 +383,6 @@ struct proxy_balancer {
apr_array_header_t *workers; /* initially configured workers */ apr_array_header_t *workers; /* initially configured workers */
apr_array_header_t *errstatuses; /* statuses to force members into error */ apr_array_header_t *errstatuses; /* statuses to force members into error */
ap_slotmem_instance_t *slot; /* worker shm data - runtime */ ap_slotmem_instance_t *slot; /* worker shm data - runtime */
proxy_balancer_method *lbmethod;
int growth; /* number of post-config workers can added */ int growth; /* number of post-config workers can added */
int max_workers; /* maximum number of allowed workers */ int max_workers; /* maximum number of allowed workers */
const char *name; /* name of the load balancer */ const char *name; /* name of the load balancer */

View File

@@ -331,7 +331,7 @@ static proxy_worker *find_best_worker(proxy_balancer *balancer,
return NULL; return NULL;
} }
candidate = (*balancer->lbmethod->finder)(balancer, r); candidate = (*balancer->s->lbmethod->finder)(balancer, r);
if (candidate) if (candidate)
candidate->s->elected++; candidate->s->elected++;
@@ -480,9 +480,9 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
/* Step 4: find the session route */ /* Step 4: find the session route */
runtime = find_session_route(*balancer, r, &route, &sticky, url); runtime = find_session_route(*balancer, r, &route, &sticky, url);
if (runtime) { if (runtime) {
if ((*balancer)->lbmethod && (*balancer)->lbmethod->updatelbstatus) { if ((*balancer)->s->lbmethod && (*balancer)->s->lbmethod->updatelbstatus) {
/* Call the LB implementation */ /* Call the LB implementation */
(*balancer)->lbmethod->updatelbstatus(*balancer, runtime, r->server); (*balancer)->s->lbmethod->updatelbstatus(*balancer, runtime, r->server);
} }
else { /* Use the default one */ else { /* Use the default one */
int i, total_factor = 0; int i, total_factor = 0;
@@ -1005,7 +1005,7 @@ static int balancer_handler(request_rec *r)
apr_time_sec(balancer->s->timeout)); apr_time_sec(balancer->s->timeout));
ap_rprintf(r, "<td align=\"center\">%d</td>\n", balancer->s->max_attempts); ap_rprintf(r, "<td align=\"center\">%d</td>\n", balancer->s->max_attempts);
ap_rprintf(r, "<td align=\"center\">%s</td>\n", ap_rprintf(r, "<td align=\"center\">%s</td>\n",
balancer->lbmethod->name); balancer->s->lbmethod->name);
ap_rputs("</table>\n<br />", r); ap_rputs("</table>\n<br />", r);
ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>" ap_rputs("\n\n<table border=\"0\" style=\"text-align: left;\"><tr>"
"<th>Worker URL</th>" "<th>Worker URL</th>"
@@ -1146,8 +1146,8 @@ static void balancer_child_init(apr_pool_t *p, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "slotmem_attach failed"); ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, s, "slotmem_attach failed");
exit(1); /* Ugly, but what else? */ exit(1); /* Ugly, but what else? */
} }
if (balancer->lbmethod && balancer->lbmethod->reset) if (balancer->s->lbmethod && balancer->s->lbmethod->reset)
balancer->lbmethod->reset(balancer, s); balancer->s->lbmethod->reset(balancer, s);
init_balancer_members(conf, s, balancer); init_balancer_members(conf, s, balancer);
balancer++; balancer++;
} }

View File

@@ -1370,7 +1370,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
memset(bshared, 0, sizeof(proxy_balancer_shared)); memset(bshared, 0, sizeof(proxy_balancer_shared));
(*balancer)->lbmethod = lbmethod; bshared->lbmethod = lbmethod;
bshared->updated = apr_time_now(); bshared->updated = apr_time_now();
bshared->was_malloced = (do_malloc != 0); bshared->was_malloced = (do_malloc != 0);