hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1563155 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
Date Fri, 31 Jan 2014 15:53:32 GMT
Author: olegk
Date: Fri Jan 31 15:53:32 2014
New Revision: 1563155

URL: http://svn.apache.org/r1563155
Log:
HTTPCORE-370: Race condition if connection request succeeds and times out at the same time

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

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1563155&r1=1563154&r2=1563155&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Jan 31 15:53:32 2014
@@ -6,6 +6,9 @@ Changes since release 4.3.1
 
 * [HTTPCORE-358] Added I/O reactor listener backlog parameter.
   Contributed by Dmitry Potapov <potapov.d at gmail.com>
+
+* [HTTPCORE-370] Race condition if connection request succeeds and times out at the same
time.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
     
 * [HTTPCORE-357] Avoid DNS lookups in SSLIOSession.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?rev=1563155&r1=1563154&r2=1563155&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
Fri Jan 31 15:53:32 2014
@@ -175,13 +175,26 @@ public class DefaultConnectingIOReactor 
                     sessionRequest.failed(ex);
                 }
                 key.cancel();
-                if (channel.isConnected()) {
+                key.attach(null);
+                if (!sessionRequest.isCompleted()) {
                     addChannel(new ChannelEntry(channel, sessionRequest));
+                } else {
+                    try {
+                        channel.close();
+                    } catch (IOException ignore) {
+                    }
                 }
             }
 
         } catch (final CancelledKeyException ex) {
+            final SessionRequestHandle requestHandle = (SessionRequestHandle) key.attachment();
             key.attach(null);
+            if (requestHandle != null) {
+                final SessionRequestImpl sessionRequest = requestHandle.getSessionRequest();
+                if (sessionRequest != null) {
+                    sessionRequest.cancel();
+                }
+            }
         }
     }
 



Mime
View raw message