hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sber...@apache.org
Subject svn commit: r672969 - in /httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http: client/ClientResponseHandler.java conn/ManagedClientConnection.java impl/conn/AbstractClientConnAdapter.java
Date Tue, 01 Jul 2008 01:09:51 GMT
Author: sberlin
Date: Mon Jun 30 18:09:50 2008
New Revision: 672969

URL: http://svn.apache.org/viewvc?rev=672969&view=rev
Log:
simplified idle duration to start counting when connection is released

Modified:
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientResponseHandler.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java
    httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientResponseHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientResponseHandler.java?rev=672969&r1=672968&r2=672969&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientResponseHandler.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientResponseHandler.java
Mon Jun 30 18:09:50 2008
@@ -36,7 +36,7 @@
 import org.apache.http.HttpResponse;
 
 /**
- * Handler that incapsulates the process of generating a response object 
+ * Handler that encapsulates the process of generating a response object 
  * from a {@link HttpResponse}.
  * 
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java?rev=672969&r1=672968&r2=672969&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java
Mon Jun 30 18:09:50 2008
@@ -249,9 +249,12 @@
         ;
     
     /**
-     * Sets the duration that this connection can remain idle
-     * before it is reused.
-     * The connection should not be used again if this time elapses.
+     * Sets the duration that this connection can remain idle before it is
+     * reused. The connection should not be used again if this time elapses. The
+     * idle duration must be reset after each request sent over this connection.
+     * The elapsed time starts counting when the connection is released, which
+     * is typically after the headers (and any response body, if present) is
+     * fully consumed.
      */
     void setIdleDuration(long duration, TimeUnit unit);
 

Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java?rev=672969&r1=672968&r2=672969&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
(original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
Mon Jun 30 18:09:50 2008
@@ -99,9 +99,6 @@
     /** True if the connection has been aborted. */
     private volatile boolean aborted;
     
-    /** The last time this processed incoming headers. */
-    private volatile long lastHeadersRead;
-    
     /** The duration this is valid for while idle (in ms). */
     private volatile long duration;
 
@@ -259,8 +256,6 @@
         assertValid(conn);
 
         unmarkReusable();
-        duration = Long.MAX_VALUE; // Reset duration per request.
-        lastHeadersRead = System.currentTimeMillis();
         return conn.receiveResponseHeader();
     }
 
@@ -361,39 +356,14 @@
         if(duration > 0) {
             this.duration = unit.toMillis(duration);
         } else {
-            this.duration = Long.MAX_VALUE;
-        }
-    }
-    
-    /**
-     * Returns the amount of time remaining that this connection
-     * can be reused.  If negative, the connection should not
-     * be reused.  If Long.MAX_VALUE, there is no suggested
-     * duration.
-     * 
-     * The remaining time is the elapsed time between now,
-     * the time the last headers were processed, and the duration
-     * given from {@link #setIdleDuration(long, TimeUnit)}.
-     */
-    protected long getRemainingIdleDuration() {
-        if(duration == Long.MAX_VALUE) {
-            return Long.MAX_VALUE;
-        } else {
-            long elapsedAlready = System.currentTimeMillis() - lastHeadersRead;
-            return duration - elapsedAlready;
+            this.duration = -1;
         }
     }
 
     // non-javadoc, see interface ConnectionReleaseTrigger
     public void releaseConnection() {
         if (connManager != null) {
-            long remainingTime = getRemainingIdleDuration();
-            if(remainingTime <= 0) {
-                unmarkReusable();
-            } else if(remainingTime == Long.MAX_VALUE) {
-                remainingTime = -1;
-            }
-            connManager.releaseConnection(this, remainingTime, TimeUnit.MILLISECONDS);
+            connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
         }
     }
 



Mime
View raw message