On 05/17/2008 09:24 PM, Ruediger Pluem wrote:


In conjunction with the last patch attached to 37770 the following patch
should finally prevent this problem at the cost of a performance penalty:

Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c  (Revision 657321)
+++ modules/proxy/proxy_util.c  (Arbeitskopie)
@@ -2168,6 +2168,11 @@
     else {
         conn->addr = worker->cp->addr;
     }
+    /* Close a possible existing socket if we are told to do so */
+    if (conn->close) {
+        socket_cleanup(conn);
+        conn->close = 0;
+    }

     if (err != APR_SUCCESS) {
         return ap_proxyerror(r, HTTP_BAD_GATEWAY,
Index: modules/proxy/mod_proxy_http.c
===================================================================
--- modules/proxy/mod_proxy_http.c      (Revision 657321)
+++ modules/proxy/mod_proxy_http.c      (Arbeitskopie)
@@ -1876,6 +1876,20 @@
         ap_proxy_ssl_connection_cleanup(backend, r);
     }

+    /*
+ * In the case that we are handling a reverse proxy connection and this + * is not a request that is coming over an already kept alive connection + * with the client, do NOT reuse the connection to the backend, because + * we cannot forward a failure to the client in this case as the client
+     * does NOT expects this in this situation.
+     * Yes, this creates a performance penalty.
+     * XXX: Make this behaviour configurable: Either via an environment
+     * variable or via a worker configuration directive.
+     */
+    if ((r->proxyreq == PROXYREQ_REVERSE) && (!c->keepalives)) {
+        backend->close = 1;
+    }
+
     /* Step One: Determine Who To Connect To */
if ((status = ap_proxy_determine_connection(p, r, conf, worker, backend,
                                                 uri, &url, proxyname,

Therefore it should be configurable. Any preferences whether to do this via an
environment variable or via a worker specific property?

I would like to fold the approach of the patch into trunk to reduce PR37770
to become (hopefully) an RTFM bug. The approach of the patch above in 
conjunction
with the reslist TTL fix in upcoming APR-UTIL 1.3.x should get us there.
Any opinions about how to make this configurable (environment variable or
via a worker specific property)?

Regards

RĂ¼diger

Reply via email to