hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1096488 - in /httpcomponents/httpasyncclient/trunk: ./ httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/ httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/
Date Mon, 25 Apr 2011 14:16:12 GMT
Author: olegk
Date: Mon Apr 25 14:16:12 2011
New Revision: 1096488

URL: http://svn.apache.org/viewvc?rev=1096488&view=rev
Log:
HTTPASYNC-3: Fixed incorrect handling of expired I/O sessions by SessionPool

Modified:
    httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/RouteSpecificPool.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java

Modified: httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt?rev=1096488&r1=1096487&r2=1096488&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpasyncclient/trunk/RELEASE_NOTES.txt Mon Apr 25 14:16:12 2011
@@ -1,3 +1,9 @@
+Changes since 4.0 Alpha 1
+
+* [HTTPASYNC-3]: Fixed incorrect handling of expired I/O sessions by SessionPool.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+
 Release 4.0 Alpha 1
 -------------------
 

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java?rev=1096488&r1=1096487&r2=1096488&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingClientConnectionManager.java
Mon Apr 25 14:16:12 2011
@@ -158,8 +158,7 @@ public class PoolingClientConnectionMana
         HttpPoolEntry entry = adaptor.getEntry();
         if (this.log.isDebugEnabled()) {
             HttpRoute route = entry.getPlannedRoute();
-            Object state = entry.getState();
-            this.log.debug("Releasing connection: route[" + route + "][state: " + state +
"]");
+            this.log.debug("Releasing connection: " + entry);
             PoolStats totals = this.pool.getTotalStats();
             PoolStats stats = this.pool.getStats(route);
             this.log.debug("Total: " + totals);
@@ -176,10 +175,7 @@ public class PoolingClientConnectionMana
                 } else {
                     s = "indefinitely";
                 }
-                HttpRoute route = entry.getPlannedRoute();
-                Object state = entry.getState();
-                this.log.debug("Pooling connection" +
-                        " [" + route + "][" + state + "]; keep alive " + s);
+                this.log.debug("Pooling connection: " + entry + "; keep alive " + s);
             }
         }
         this.pool.release(entry, reusable);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/RouteSpecificPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/RouteSpecificPool.java?rev=1096488&r1=1096487&r2=1096488&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/RouteSpecificPool.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/RouteSpecificPool.java
Mon Apr 25 14:16:12 2011
@@ -75,15 +75,10 @@ class RouteSpecificPool<T, E extends Poo
             ListIterator<E> it = this.availableSessions.listIterator(this.availableSessions.size());
             while (it.hasPrevious()) {
                 E entry = it.previous();
-                IOSession iosession = entry.getIOSession();
-                if (iosession.isClosed() || entry.isExpired(System.currentTimeMillis()))
{
+                if (entry.getState() == null || entry.getState().equals(state)) {
                     it.remove();
-                } else {
-                    if (entry.getState() == null || entry.getState().equals(state)) {
-                        it.remove();
-                        this.leasedSessions.add(entry);
-                        return entry;
-                    }
+                    this.leasedSessions.add(entry);
+                    return entry;
                 }
             }
         }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java?rev=1096488&r1=1096487&r2=1096488&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/pool/SessionPool.java
Mon Apr 25 14:16:12 2011
@@ -204,7 +204,20 @@ public abstract class SessionPool<T, E e
             }
 
             RouteSpecificPool<T, E> pool = getPool(request.getRoute());
-            E entry = pool.getFreeEntry(state);
+            E entry = null;
+            for (;;) {
+                entry = pool.getFreeEntry(state);
+                if (entry == null) {
+                    break;
+                }
+                IOSession iosession = entry.getIOSession();
+                if (iosession.isClosed() || entry.isExpired(System.currentTimeMillis()))
{
+                    this.availableSessions.remove(entry);
+                    pool.freeEntry(entry, false);
+                } else {
+                    break;
+                }
+            }
             if (entry != null) {
                 it.remove();
                 this.availableSessions.remove(entry);
@@ -227,6 +240,7 @@ public abstract class SessionPool<T, E e
                             route,
                             this.sessionRequestCallback);
                     sessionRequest.setConnectTimeout(timeout);
+                    this.pendingSessions.add(sessionRequest);
                     pool.addPending(sessionRequest, callback);
                 }
             }



Mime
View raw message