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 2009/09/03 19:16:09 UTC
svn commit: r811039 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt
httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
Author: olegk
Date: Thu Sep 3 17:16:09 2009
New Revision: 811039
URL: http://svn.apache.org/viewvc?rev=811039&view=rev
Log:
Ensure that an attempt is made to close out all active sessions gracefully in case of an abnormal shutdown of the I/O reactor
Modified:
httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=811039&r1=811038&r2=811039&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Thu Sep 3 17:16:09 2009
@@ -7,6 +7,10 @@
Please note new classes and methods added in the 4.1 branch are still considered API unstable.
+* Ensure that an attempt is made to close out all active sessions gracefully in case of an abnormal
+ shutdown of the I/O reactor.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-201] OSGi Export-Package to specify release version
Contributed by Oleg Kalnichevski <olegk at apache.org>
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=811039&r1=811038&r2=811039&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java Thu Sep 3 17:16:09 2009
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.channels.CancelledKeyException;
-import java.nio.channels.Channel;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.SelectionKey;
@@ -302,11 +301,12 @@
// Close remaining active channels and the selector itself
closeActiveChannels();
+ this.status = IOReactorStatus.SHUT_DOWN;
} catch (ClosedSelectorException ex) {
} finally {
synchronized (this.shutdownMutex) {
- this.status = IOReactorStatus.SHUT_DOWN;
+ hardShutdown();
this.shutdownMutex.notifyAll();
}
}
@@ -524,18 +524,16 @@
* @throws IOReactorException - not thrown currently
*/
protected void closeActiveChannels() throws IOReactorException {
- Set<SelectionKey> keys = this.selector.keys();
- for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext(); ) {
- try {
+ try {
+ Set<SelectionKey> keys = this.selector.keys();
+ for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext(); ) {
SelectionKey key = it.next();
- Channel channel = key.channel();
- if (channel != null) {
- channel.close();
+ IOSession session = getSession(key);
+ if (!session.isClosed()) {
+ session.close();
+ sessionClosed(session);
}
- } catch (IOException ignore) {
}
- }
- try {
this.selector.close();
} catch (IOException ignore) {
}