hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r580938 - in /jakarta/httpcomponents/httpcore/trunk: RELEASE_NOTES.txt module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
Date Mon, 01 Oct 2007 13:01:36 GMT
Author: olegk
Date: Mon Oct  1 06:01:33 2007
New Revision: 580938

URL: http://svn.apache.org/viewvc?rev=580938&view=rev
Log:
HTTPCORE-118: Purge closed sessions prior to opening new ones. This should reduce chances
of running out of memory when opening and closing lots of NIO connections in a tight loop.

Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=580938&r1=580937&r2=580938&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Mon Oct  1 06:01:33 2007
@@ -1,5 +1,10 @@
 Changes since release 4.0 Alpha 5
 
+* [HTTPCORE-118] Purge closed sessions prior to opening new ones. This should reduce 
+  chances of running out of memory when opening and closing lots of NIO connections in a

+  tight loop. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-117] Fixed bug preventing protocol handlers from closing timed out NIO connection

   when pending output (output session buffer is not empty). 
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=580938&r1=580937&r2=580938&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
Mon Oct  1 06:01:33 2007
@@ -131,8 +131,6 @@
                     break;
                 }
 
-                processNewChannels();
-                
                 if (readyCount > 0) {
                     processEvents(this.selector.selectedKeys());
                 }
@@ -141,6 +139,10 @@
                 
                 processClosedSessions();
 
+                if (this.status == ACTIVE) {
+                    processNewChannels();
+                }
+                
                 if (this.status != ACTIVE && this.sessions.isEmpty()) {
                     break;
                 }
@@ -258,7 +260,20 @@
     }
     
     protected void closeChannels() throws IOReactorException {
-        // Close out all channels
+        // Close out all new channels
+        ChannelEntry entry;
+        while ((entry = this.newChannels.pop()) != null) {
+            SessionRequestImpl sessionRequest = entry.getSessionRequest();
+            if (sessionRequest != null) {
+                sessionRequest.cancel();
+            }
+            SocketChannel channel = entry.getChannel();
+            try {
+                channel.close();
+            } catch (IOException ignore) {
+            }
+        }
+        // Close out all active channels
         Set keys = this.selector.keys();
         for (Iterator it = keys.iterator(); it.hasNext(); ) {
             try {



Mime
View raw message