You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2008/03/01 14:58:41 UTC
svn commit: r632593 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt
module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
Author: olegk
Date: Sat Mar 1 05:58:40 2008
New Revision: 632593
URL: http://svn.apache.org/viewvc?rev=632593&view=rev
Log:
HTTPCORE-149: I/O reactors now count period of inactivity since the time of the last read or write operation. Previously only read operations resulted in timeout counter reset
Modified:
httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=632593&r1=632592&r2=632593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Sat Mar 1 05:58:40 2008
@@ -1,7 +1,12 @@
Changes since 4.0 Beta 1
-------------------
-* [HTTPCORE-147] Improved asynchronous server and client HTTP protocol
+* [HTTPCORE-149] I/O reactors now count period of inactivity since the
+ time of the last read or write operation. Previously only read
+ operations resulted in timeout counter reset.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* [HTTPCORE-148] Improved asynchronous server and client HTTP protocol
handler implementations.
Contributed by Sam Berlin <sberlin at gmail.com>
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=632593&r1=632592&r2=632593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Sat Mar 1 05:58:40 2008
@@ -48,12 +48,12 @@
private final long timeoutCheckInterval;
private final Set<IOSession> bufferingSessions;
-
+
private long lastTimeoutCheck;
-
+
private IOReactorExceptionHandler exceptionHandler = null;
private IOEventDispatch eventDispatch = null;
-
+
public BaseIOReactor(long selectTimeout) throws IOReactorException {
super(selectTimeout);
this.bufferingSessions = new HashSet<IOSession>();
@@ -109,14 +109,14 @@
SessionHandle handle = (SessionHandle) key.attachment();
IOSession session = handle.getSession();
handle.resetLastWrite();
-
+
try {
this.eventDispatch.outputReady(session);
} catch (RuntimeException ex) {
handleRuntimeException(ex);
}
}
-
+
@Override
protected void validate(final Set<SelectionKey> keys) {
long currentTime = System.currentTimeMillis();
@@ -163,7 +163,7 @@
IOSession session = handle.getSession();
int timeout = session.getSocketTimeout();
if (timeout > 0) {
- if (handle.getLastReadTime() + timeout < now) {
+ if (handle.getLastAccessTime() + timeout < now) {
try {
this.eventDispatch.timeout(session);
} catch (RuntimeException ex) {
@@ -176,7 +176,7 @@
@Override
protected void keyCreated(final SelectionKey key, final IOSession session) {
- SessionHandle handle = new SessionHandle(session);
+ SessionHandle handle = new SessionHandle(session);
key.attach(handle);
try {
this.eventDispatch.connected(session);
@@ -184,7 +184,7 @@
handleRuntimeException(ex);
}
}
-
+
@Override
protected IOSession keyCancelled(final SelectionKey key) {
Object attachment = key.attachment();
@@ -204,5 +204,5 @@
handleRuntimeException(ex);
}
}
-
+
}
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java?rev=632593&r1=632592&r2=632593&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionHandle.java Sat Mar 1 05:58:40 2008
@@ -40,7 +40,8 @@
private long lastReadTime;
private long lastWriteTime;
-
+ private long lastAccessTime;
+
public SessionHandle(final IOSession session) {
super();
if (session == null) {
@@ -51,6 +52,7 @@
this.startedTime = now;
this.lastReadTime = now;
this.lastWriteTime = now;
+ this.lastAccessTime = now;
}
public IOSession getSession() {
@@ -68,13 +70,21 @@
public long getLastWriteTime() {
return this.lastWriteTime;
}
-
+
+ public long getLastAccessTime() {
+ return this.lastAccessTime;
+ }
+
public void resetLastRead() {
- this.lastReadTime = System.currentTimeMillis();
+ long now = System.currentTimeMillis();
+ this.lastReadTime = now;
+ this.lastAccessTime = now;
}
-
+
public void resetLastWrite() {
- this.lastWriteTime = System.currentTimeMillis();
+ long now = System.currentTimeMillis();
+ this.lastWriteTime = now;
+ this.lastAccessTime = now;
}
-
+
}