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

Move worker params parsing to a separate function.

The same will be used for creating ProxyPass connection pools.

Added ttl param to worker for maintaining reslist.

Submitted by: mturk


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104570 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
William A. Rowe Jr
2004-08-11 21:29:57 +00:00
parent e881f5cc72
commit 8dda80bccc
2 changed files with 51 additions and 11 deletions

View File

@@ -73,6 +73,52 @@ static unsigned char hex2c(const char* p) {
} }
#endif #endif
static const char *set_worker_param(proxy_worker *worker,
const char *key,
const char *val)
{
int ival;
if (!strcasecmp(key, "loadfactor")) {
worker->lbfactor = atoi(val);
if (worker->lbfactor < 1 || worker->lbfactor > 100)
return "loadfactor must be number between 1..100";
}
else if (!strcasecmp(key, "retry")) {
ival = atoi(val);
if (ival < 1)
return "retry must be al least one second";
worker->retry = apr_time_from_sec(ival);
}
else if (!strcasecmp(key, "ttl")) {
ival = atoi(val);
if (ival < 1)
return "ttl must be al least one second";
worker->ttl = apr_time_from_sec(ival);
}
else if (!strcasecmp(key, "min")) {
ival = atoi(val);
if (ival < 0)
return "min must be a positive number";
worker->min = ival;
}
else if (!strcasecmp(key, "max")) {
ival = atoi(val);
if (ival < 0)
return "max must be a positive number";
worker->hmax = ival;
}
/* XXX: More inteligent naming needed */
else if (!strcasecmp(key, "smax")) {
ival = atoi(val);
if (ival < 0)
return "smax must be a positive number";
worker->smax = ival;
}
return NULL;
}
static int alias_match(const char *uri, const char *alias_fakename) static int alias_match(const char *uri, const char *alias_fakename)
{ {
const char *end_fakename = alias_fakename + strlen(alias_fakename); const char *end_fakename = alias_fakename + strlen(alias_fakename);
@@ -1080,17 +1126,9 @@ static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg)
arr = apr_table_elts(params); arr = apr_table_elts(params);
elts = (const apr_table_entry_t *)arr->elts; elts = (const apr_table_entry_t *)arr->elts;
for (i = 0; i < arr->nelts; i++) { for (i = 0; i < arr->nelts; i++) {
if (!strcasecmp(elts[i].key, "loadfactor")) { const char *err = set_worker_param(worker, elts[i].key, elts[i].val);
worker->lbfactor = atoi(elts[i].val); if (err)
if (worker->lbfactor < 1 || worker->lbfactor > 100) return apr_pstrcat(cmd->temp_pool, "BalancerMember: ", err, NULL);
return "BalancerMember: loadfactor must be number between 1..100";
}
else if (!strcasecmp(elts[i].key, "retry")) {
int sec = atoi(elts[i].val);
if (sec < 0)
return "BalancerMember: retry must be positive number";
worker->retry = apr_time_from_sec(sec);
}
} }
/* Try to find the balancer */ /* Try to find the balancer */
balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, name); balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, name);

View File

@@ -223,6 +223,8 @@ typedef struct {
int min; /* Desired minimum number of available connections */ int min; /* Desired minimum number of available connections */
int smax; /* Soft maximum on the total number of connections */ int smax; /* Soft maximum on the total number of connections */
int hmax; /* Hard maximum on the total number of connections */ int hmax; /* Hard maximum on the total number of connections */
apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
* may be available while exceeding the soft limit */
proxy_conn_pool *cp; /* Connection pool to use */ proxy_conn_pool *cp; /* Connection pool to use */
void *opaque; /* per scheme worker data */ void *opaque; /* per scheme worker data */
} proxy_worker; } proxy_worker;