hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1134569 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
Date Sat, 11 Jun 2011 11:04:47 GMT
Author: olegk
Date: Sat Jun 11 11:04:46 2011
New Revision: 1134569

URL: http://svn.apache.org/viewvc?rev=1134569&view=rev
Log:
HTTPCORE-260: Non-blocking SSL I/O session can terminate prematurely causing message body
truncation when message content is chunk coded and the connection is closed on the opposite
end

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

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=1134569&r1=1134568&r2=1134569&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Sat Jun 11 11:04:46 2011
@@ -1,6 +1,10 @@
 Changes since 4.1.1
 -------------------
 
+* [HTTPCORE-260] Non-blocking SSL I/O session can terminate prematurely causing message body

+  truncation when message content is chunk coded and the connection is closed on the opposite
end. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCORE-257] Fixed incorrect results produced by DefaultConnectionReuseStrategy when
handling 
   response messages whose content entity has been decoded or modified by a protocol interceptor.

   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java?rev=1134569&r1=1134568&r2=1134569&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SSLIOSession.java
Sat Jun 11 11:04:46 2011
@@ -164,9 +164,6 @@ public class SSLIOSession implements IOS
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
                 }
-                if (result.getStatus() == Status.CLOSED) {
-                    this.status = CLOSED;
-                }
                 break;
             case NEED_UNWRAP:
                 // Process incoming handshake data
@@ -176,12 +173,6 @@ public class SSLIOSession implements IOS
                 if (result.getStatus() != Status.OK) {
                     handshaking = false;
                 }
-                if (result.getStatus() == Status.CLOSED) {
-                    this.status = CLOSED;
-                }
-                if (result.getStatus() == Status.BUFFER_UNDERFLOW && this.endOfStream)
{
-                    this.status = CLOSED;
-                }
                 break;
             case NEED_TASK:
                 Runnable r = this.sslEngine.getDelegatedTask();
@@ -206,7 +197,8 @@ public class SSLIOSession implements IOS
     }
 
     private void updateEventMask() {
-        if (this.sslEngine.isInboundDone() && this.sslEngine.isOutboundDone()) {
+        if (this.status == CLOSING &&
+                this.sslEngine.isInboundDone() && this.sslEngine.isOutboundDone())
{
             this.status = CLOSED;
         }
         if (this.status == CLOSED) {
@@ -263,12 +255,6 @@ public class SSLIOSession implements IOS
             this.inEncrypted.compact();
 
             opStatus = result.getStatus();
-            if (opStatus == Status.CLOSED) {
-                this.status = CLOSED;
-            }
-            if (opStatus == Status.BUFFER_UNDERFLOW && this.endOfStream) {
-                this.status = CLOSED;
-            }
             if (opStatus == Status.OK) {
                 decrypted = true;
             }
@@ -359,18 +345,19 @@ public class SSLIOSession implements IOS
         }
     }
 
-    public void close() {
-        if (this.status != ACTIVE) {
+    public synchronized void close() {
+        if (this.status >= CLOSING) {
             return;
         }
         this.status = CLOSING;
-        synchronized(this) {
-            this.sslEngine.closeOutbound();
-            updateEventMask();
-        }
+        this.sslEngine.closeOutbound();
+        updateEventMask();
     }
 
-    public void shutdown() {
+    public synchronized void shutdown() {
+        if (this.status == CLOSED) {
+            return;
+        }
         this.status = CLOSED;
         this.session.shutdown();
     }
@@ -380,7 +367,7 @@ public class SSLIOSession implements IOS
     }
 
     public boolean isClosed() {
-        return this.status != ACTIVE;
+        return this.status >= CLOSING;
     }
 
     public synchronized boolean isInboundDone() {
@@ -476,6 +463,9 @@ public class SSLIOSession implements IOS
         }
         buffer.append("][");
         buffer.append(this.sslEngine.getHandshakeStatus());
+        if (this.endOfStream) {
+            buffer.append("EOF][");
+        }
         buffer.append("][");
         buffer.append(this.inEncrypted.position());
         buffer.append("][");



Mime
View raw message