]> granicus.if.org Git - apache/commitdiff
Added acquire timeout for obtaining resources from reslist.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 11 Aug 2004 22:30:06 +0000 (22:30 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 11 Aug 2004 22:30:06 +0000 (22:30 +0000)
The timeout is in milliseconds to enable quick return in case the
reslist is exceded the maximum number of connections.

Submitted by: mturk

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104591 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c

index f661f4cd9d5a5380e6f6d5adab368524c7a08ef5..5d863b2e38c824231437e0a3f6a7b0a677507e91 100644 (file)
@@ -92,7 +92,7 @@ static const char *set_worker_param(proxy_worker *worker,
     else if (!strcasecmp(key, "ttl")) {
         ival = atoi(val);
         if (ival < 1)
-            return "ttl must be al least one second";
+            return "ttl must be at least one second";
         worker->ttl = apr_time_from_sec(ival);
     }
     else if (!strcasecmp(key, "min")) {
@@ -114,6 +114,13 @@ static const char *set_worker_param(proxy_worker *worker,
             return "smax must be a positive number";
         worker->smax = ival;
     }
+    else if (!strcasecmp(key, "acquire")) {
+        ival = atoi(val);
+        if (ival < 1)
+            return "acquire must be at least one mili second";
+        worker->acquire = apr_time_make(0, ival * 1000);
+        worker->acquire_set = 1;
+     }
     else {
         return "unknown parameter";
     }
index 22073230887261e5704fd9be44689a7eaf397cc9..06eb00a2ebd637191381f3f259307b680719d705 100644 (file)
@@ -228,7 +228,8 @@ struct proxy_worker {
     apr_interval_time_t ttl;    /* maximum amount of time in seconds a connection
                                  * may be available while exceeding the soft limit */
     apr_interval_time_t timeout; /* connection timeout */
-
+    apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
+    char                acquire_set;
     proxy_conn_pool *cp;        /* Connection pool to use */
     void            *opaque;    /* per scheme worker data */
 };
index 8a39c43b026c4564fad8f08abd3af90324957cc2..09f3bfa915c104dd90dc481c0dc07ba8892298b9 100644 (file)
@@ -1364,6 +1364,37 @@ static apr_status_t connection_destructor(void *resource, void *params,
     return APR_SUCCESS;
 }
 
+/* low level connection acquire/release functions
+ * they are hiding apr_reslist for nothreaded or prefork servers.
+ */
+static apr_status_t acquire_connection_low(proxy_conn_rec **conn, proxy_worker *worker)
+{
+    apr_status_t rv;
+#if APR_HAS_THREADS
+    if (worker->hmax) {
+        rv = apr_reslist_acquire(worker->cp->res, (void **)conn);
+    }
+    else
+#endif
+    {
+        *conn = worker->cp->conn;
+        rv = APR_SUCCESS;
+    }
+    return rv;
+}
+
+static apr_status_t release_connection_low(proxy_conn_rec *conn, proxy_worker *worker)
+{
+    apr_status_t rv = APR_SUCCESS;
+#if APR_HAS_THREADS
+    if (worker->hmax) {
+        rv = apr_reslist_release(worker->cp->res, (void *)conn);
+    }
+#endif
+    return rv;
+}
+
+
 static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
 {
     apr_status_t rv;
@@ -1374,6 +1405,11 @@ static apr_status_t init_conn_worker(proxy_worker *worker, server_rec *s)
                                 worker->hmax, worker->ttl,
                                 connection_constructor, connection_destructor,
                                 s, worker->cp->pool);
+#if (APR_MAJOR_VERSION > 0)
+        /* Set the acquire timeout */
+        if (rv == APR_SUCCESS && worker->acquire_set)
+            apr_reslist_timeout_set(worker->cp->res, worker->acquire);
+#endif
     }
     else
 #endif