Author: jfrederic.clere(a)jboss.com
Date: 2008-06-18 11:19:18 -0400 (Wed, 18 Jun 2008)
New Revision: 1720
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Make sure the ping/pong only waits the ping value even if we have to build a new
connection.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-18 08:59:03 UTC
(rev 1719)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-18 15:19:18 UTC
(rev 1720)
@@ -218,9 +218,12 @@
balancer_storage->read_balancer(bal[i], &balan);
/* Something like cluster://cluster1 and cluster1 */
if (strcmp(balan->balancer, &balancer->name[10]) == 0) {
- /* XXX: not yet finished
- balancer->sticky
- balancer->sticky_force */
+ /* XXX: StickySession, StickySessionRemove not in */
+ balancer->sticky = apr_psprintf(pool, "%s|%s",
balan->StickySessionCookie,
+ balan->StickySessionPath);
+ balancer->sticky_force = balan->StickySessionForce;
+ balancer->timeout = apr_time_from_sec(balan->Timeout);
+
balancer->max_attempts = balan->Maxattempts;
balancer->max_attempts_set = 1;
break;
@@ -847,6 +850,8 @@
apr_status_t rv;
proxy_conn_rec *conn;
apr_interval_time_t timeout;
+ apr_interval_time_t savetimeout;
+ char savetimeout_set;
#if AP_MODULE_MAGIC_AT_LEAST(20051115,4)
#else
proxy_cluster_helper *helperping;
@@ -920,8 +925,30 @@
}
}
+ /* Set the timeout: Note that the default timeout logic in the proxy_util.c is:
+ * 1 - worker->timeout (if timeout_set timeout=n in the worker)
+ * 2 - conf->timeout (if timeout_set ProxyTimeout 300)
+ * 3 - s->timeout (TimeOut 300).
+ * We hack it... Via 1
+ */
+#if AP_MODULE_MAGIC_AT_LEAST(20051115,4)
+ timeout = worker->ping_timeout;
+#else
+ helperping = worker->opaque;
+ timeout = helperping->ping_timeout;
+#endif
+ if (timeout <= 0)
+ timeout = apr_time_from_sec(10); /* 10 seconds */
+
+ savetimeout_set = worker->timeout_set;
+ savetimeout = worker->timeout;
+ worker->timeout_set = 1;
+ worker->timeout = timeout;
+
/* Connect to the backend: Check connected/reuse otherwise create new */
rv = ap_proxy_connect_backend(scheme, conn, worker, r->server);
+ worker->timeout_set = savetimeout_set;
+ worker->timeout = savetimeout;
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy_cluster_try_pingpong: can't connect to
backend");
@@ -929,15 +956,6 @@
return rv;
}
-#if AP_MODULE_MAGIC_AT_LEAST(20051115,4)
- timeout = worker->ping_timeout;
-#else
- helperping = worker->opaque;
- timeout = helperping->ping_timeout;
-#endif
- if (timeout <= 0)
- timeout = apr_time_from_sec(10); /* 10 seconds */
-
/* XXX: For the moment we support only AJP */
if (strcasecmp(scheme, "AJP") == 0) {
rv = ajp_handle_cping_cpong(conn->sock, r, timeout);