]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r394088 and r395180 from trunk.
authorPaul Querna <pquerna@apache.org>
Sat, 22 Apr 2006 01:33:44 +0000 (01:33 +0000)
committerPaul Querna <pquerna@apache.org>
Sat, 22 Apr 2006 01:33:44 +0000 (01:33 +0000)
PR: 38793
Reviewed By: rpluem, jim, wrowe, trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@396049 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
include/ap_mmn.h
modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_http.c
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index 39ca737a0f09fb5de3b588acb98fb0ad43b93599..09317de185146bdae8771a60f71dafe0acb630e2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,9 @@ Changes with Apache 2.2.2
   *) mod_deflate: work correctly in an internal redirect
      [Brian J. France <list firehawksystems com>]
 
+  *) mod_proxy: Do not release connections from connection pool twice.
+     PR 38793. [Ruediger Pluem, matthias <mk-asf gigacodes.de>]
+
   *) core: Prevent reading uninitialized memory while reading a line of
      protocol input.  PR 39282. [Davi Arnaut <davi haxent.com.br>]
 
diff --git a/STATUS b/STATUS
index dde63e874099033301a8b838938d88d2f4d13136..8f4d8e84c9430475616791aa13add9b0133634aa 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -75,17 +75,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_proxy: Do not release connections from connection pool twice as this
-                 can cause different threads to use the same connection at the
-                 same time. PR 38793.
-        Trunk version of patch:
-          http://svn.apache.org/viewcvs?rev=394088&view=rev
-        2.2.x version of patch:
-          Trunk version works
-      +1: rpluem, jim, wrowe (with trawick's observation),
-          trawick (with rev 395180)
-      trawick: needs http://svn.apache.org/viewcvs?rev=395180&view=rev
-
     * mod_proxy_balancer: Initialize local data structures for workers of a
                           balancer. PR 38227, PR 38267.
         Trunk version of patch:
index 8d2786878f89dc080eb3feebd442ecb15a9e6918..41019802a90827218ed0525a695e70ccf01dbeb1 100644 (file)
  * 20051115.0 (2.1.10-dev/2.2.0) add use_canonical_phys_port to core_dir_config
  * 20051115.1 (2.2.1)  flush_packets and flush_wait members added to
  *                         proxy_server (minor)
+ * 20051115.2 (2.2.2)  added inreslist member to proxy_conn_rec (minor)
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20051115
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 6991b4d067526eb8917f47121201daf50ad2bc8e..57a7076b35886c1b2b60b593c124c72b262f00b7 100644 (file)
@@ -221,6 +221,9 @@ typedef struct {
     int          close_on_recycle; /* Close the connection when returning to pool */
     proxy_worker *worker;   /* Connection pool this connection belogns to */
     void         *data;     /* per scheme connection data */
+#if APR_HAS_THREADS
+    int          inreslist; /* connection in apr_reslist? */
+#endif
 } proxy_conn_rec;
 
 typedef struct {
index fa28451b7d59d008a761c3250b5825875431504b..cddd535b4dc940aaceb72892b919cf4ff8001b92 100644 (file)
@@ -1230,7 +1230,6 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
             ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                           "proxy: error reading status line from remote "
                           "server %s", backend->hostname);
-            ap_proxy_http_cleanup(NULL, r, backend);
             return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                                  "Error reading from remote server");
         }
@@ -1251,7 +1250,6 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
              * if the status line was > 8192 bytes
              */
             else if ((buffer[5] != '1') || (len >= sizeof(buffer)-1)) {
-                ap_proxy_http_cleanup(NULL, r, backend);
                 return ap_proxyerror(r, HTTP_BAD_GATEWAY,
                 apr_pstrcat(p, "Corrupt status line returned by remote "
                             "server: ", buffer, NULL));
index d117c643e5a6a68f04c3750fa572e13171998b4e..fe0e91f4ab15fb3f4130a665d77afdc3ace8e2c5 100644 (file)
@@ -1515,7 +1515,18 @@ static apr_status_t connection_cleanup(void *theconn)
     if (!worker->cp)
         return APR_SUCCESS;
 
-    /* deterimine if the connection need to be closed */
+#if APR_HAS_THREADS
+    /* Sanity check: Did we already return the pooled connection? */
+    if (conn->inreslist) {
+        ap_log_perror(APLOG_MARK, APLOG_ERR, 0, conn->pool,
+                      "proxy: Pooled connection 0x%pp for worker %s has been"
+                      " already returned to the connection pool.", conn,
+                      worker->name);
+        return APR_SUCCESS;
+    }
+#endif
+
+    /* determine if the connection need to be closed */
     if (conn->close_on_recycle || conn->close) {
         apr_pool_t *p = conn->pool;
         apr_pool_clear(conn->pool);
@@ -1525,6 +1536,7 @@ static apr_status_t connection_cleanup(void *theconn)
     }
 #if APR_HAS_THREADS
     if (worker->hmax && worker->cp->res) {
+        conn->inreslist = 1;
         apr_reslist_release(worker->cp->res, (void *)conn);
     }
     else
@@ -1555,6 +1567,9 @@ static apr_status_t connection_constructor(void **resource, void *params,
 
     conn->pool   = ctx;
     conn->worker = worker;
+#if APR_HAS_THREADS
+    conn->inreslist = 1;
+#endif
     *resource = conn;
 
     return APR_SUCCESS;
@@ -1787,6 +1802,9 @@ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
     (*conn)->worker = worker;
     (*conn)->close  = 0;
     (*conn)->close_on_recycle = 0;
+#if APR_HAS_THREADS
+    (*conn)->inreslist = 0;
+#endif
 
     return OK;
 }