]> granicus.if.org Git - apache/commitdiff
Move worker params parsing to a separate function.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 11 Aug 2004 21:29:57 +0000 (21:29 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 11 Aug 2004 21:29:57 +0000 (21:29 +0000)
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
modules/proxy/mod_proxy.h

index 26494636467b85cdc2331f00b43abec432b30950..ff92333b23ebbecf3f91906b641e2ab7f7d4dcd8 100644 (file)
@@ -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); 
index 4a79b9779889bc198e0f5eb7ffea41ce5c3664ef..bff5ee6fcdc78507d5d65c51ba5b830b36828b75 100644 (file)
@@ -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;