hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1489445 - in /httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool: AbstractNIOConnPool.java LeaseRequest.java
Date Tue, 04 Jun 2013 13:48:39 GMT
Author: olegk
Date: Tue Jun  4 13:48:39 2013
New Revision: 1489445

URL: http://svn.apache.org/r1489445
Log:
NIO connection pool was found to stop processing of pending requests prematurely (for instance,
upon a request timeout) which could lead to unnecessary delays in connection allocation. When
processing the next pending request the pool should continue iterating over pending requests
until one of two conditions is met: a pending request has been successfully handled by either
allocating a persistent connection or by requesting a new connection or the queue has been
fully exhausted.

Modified:
    httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
    httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/LeaseRequest.java

Modified: httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1489445&r1=1489444&r2=1489445&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
(original)
+++ httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
Tue Jun  4 13:48:39 2013
@@ -187,7 +187,8 @@ public abstract class AbstractNIOConnPoo
             long timeout = connectTimeout > 0 ? tunit.toMillis(connectTimeout) : 0;
             BasicFuture<E> future = new BasicFuture<E>(callback);
             LeaseRequest<T, C, E> request = new LeaseRequest<T, C, E>(route,
state, timeout, future);
-            if (!processPendingRequest(request)) {
+            boolean completed = processPendingRequest(request);
+            if (!request.isDone() && !completed) {
                 this.leasingRequests.add(request);
             }
             return future;
@@ -232,7 +233,8 @@ public abstract class AbstractNIOConnPoo
         ListIterator<LeaseRequest<T, C, E>> it = this.leasingRequests.listIterator();
         while (it.hasNext()) {
             LeaseRequest<T, C, E> request = it.next();
-            if (processPendingRequest(request)) {
+            processPendingRequest(request);
+            if (request.isDone()) {
                 it.remove();
             }
         }
@@ -242,8 +244,11 @@ public abstract class AbstractNIOConnPoo
         ListIterator<LeaseRequest<T, C, E>> it = this.leasingRequests.listIterator();
         while (it.hasNext()) {
             LeaseRequest<T, C, E> request = it.next();
-            if (processPendingRequest(request)) {
+            boolean completed = processPendingRequest(request);
+            if (request.isDone() || completed) {
                 it.remove();
+            }
+            if (completed) {
                 return;
             }
         }
@@ -258,7 +263,7 @@ public abstract class AbstractNIOConnPoo
         long now = System.currentTimeMillis();
         if (now > deadline) {
             future.failed(new TimeoutException());
-            return true;
+            return false;
         }
 
         RouteSpecificPool<T, C, E> pool = getPool(route);

Modified: httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/LeaseRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/LeaseRequest.java?rev=1489445&r1=1489444&r2=1489445&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/LeaseRequest.java
(original)
+++ httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/main/java/org/apache/http/nio/pool/LeaseRequest.java
Tue Jun  4 13:48:39 2013
@@ -73,6 +73,10 @@ class LeaseRequest<T, C, E extends PoolE
         return this.future;
     }
 
+    public boolean isDone() {
+        return this.future.isDone();
+    }
+
     @Override
     public String toString() {
         StringBuilder buffer = new StringBuilder();



Mime
View raw message