From 8dda80bcccbe4a41333d87db4d752fed648e7a58 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 11 Aug 2004 21:29:57 +0000 Subject: [PATCH] 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 --- modules/proxy/mod_proxy.c | 60 ++++++++++++++++++++++++++++++++------- modules/proxy/mod_proxy.h | 2 ++ 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 2649463646..ff92333b23 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -73,6 +73,52 @@ static unsigned char hex2c(const char* p) { } #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) { 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); elts = (const apr_table_entry_t *)arr->elts; for (i = 0; i < arr->nelts; i++) { - if (!strcasecmp(elts[i].key, "loadfactor")) { - worker->lbfactor = atoi(elts[i].val); - if (worker->lbfactor < 1 || worker->lbfactor > 100) - 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); - } + const char *err = set_worker_param(worker, elts[i].key, elts[i].val); + if (err) + return apr_pstrcat(cmd->temp_pool, "BalancerMember: ", err, NULL); } /* Try to find the balancer */ balancer = ap_proxy_get_balancer(cmd->temp_pool, conf, name); diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 4a79b97798..bff5ee6fcd 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -223,6 +223,8 @@ typedef struct { int min; /* Desired minimum number of available connections */ int smax; /* Soft 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 */ void *opaque; /* per scheme worker data */ } proxy_worker; -- 2.50.1