Fix the performance issue, don't count down until the lock has been released, this...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Oct 2008 02:15:35 +0000 (02:15 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Oct 2008 02:15:35 +0000 (02:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708753 13f79535-47bb-0310-9956-ffa450edef68

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

index f60a7a2..477d8c9 100644 (file)
@@ -50,17 +50,18 @@ public class FairBlockingQueue<E> implements BlockingQueue<E> {
     public boolean offer(E e) {
         final ReentrantLock lock = this.lock;
         lock.lock();
+        ExchangeCountDownLatch<E> c = null;
         try {
             if (waiters.size() > 0) {
-                ExchangeCountDownLatch<E> c = waiters.poll();
+                c = waiters.poll();
                 c.setItem(e);
-                c.countDown();
             } else {
                 items.add(e);
             }
         } finally {
             lock.unlock();
         }
+        if (c!=null) c.countDown();
         return true;
     }