Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49584
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 15 Sep 2010 13:24:14 +0000 (13:24 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 15 Sep 2010 13:24:14 +0000 (13:24 +0000)
Move the offering of a new thread on release from the abandoned connection code to the release code to eliminate the possibility of a blocked thread on release.

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

modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

index 81a8779..8b00d70 100644 (file)
@@ -466,9 +466,6 @@ public class ConnectionPool {
             }
             //release the connection
             release(con);
-            //we've asynchronously reduced the number of connections
-            //we could have threads stuck in idle.poll(timeout) that will never be notified
-            if (waitcount.get()>0) idle.offer(new PooledConnection(poolProperties,this));
         } finally {
             con.unlock();
         }
@@ -517,6 +514,12 @@ public class ConnectionPool {
         } finally {
             con.unlock();
         }
+        // we've asynchronously reduced the number of connections
+        // we could have threads stuck in idle.poll(timeout) that will never be
+        // notified
+        if (waitcount.get() > 0) {
+            idle.offer(new PooledConnection(poolProperties, this));
+        }
     }
 
     /**