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/08/29 10:37:43 UTC

svn commit: r690151 - in /httpcomponents/httpcore/trunk: RELEASE_NOTES.txt module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java

Author: olegk
Date: Fri Aug 29 01:37:42 2008
New Revision: 690151

URL: http://svn.apache.org/viewvc?rev=690151&view=rev
Log:
HTTPCORE-170: Race condition in SharedOutputBuffer may cause a connection to hang
Contributed by Jason Walton <Jason.Walton at alcatel-lucent.com>
Reviewed by Oleg Kalnichevski


Modified:
    httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java

Modified: httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?rev=690151&r1=690150&r2=690151&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Fri Aug 29 01:37:42 2008
@@ -1,6 +1,9 @@
 Changes since 4.0 Beta 2
 -------------------
 
+* [HTTPCORE-170] Fixed race condition in SharedOutputBuffer.
+  Contributed by Jason Walton <Jason.Walton at alcatel-lucent.com>
+
 * [HTTPCORE-169] Fixed bug causing connecting I/O reactors to shut down due to
   ClosedChannelException if a pending session request is cancelled before the new
   channel has been registered with the selector.

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java?rev=690151&r1=690150&r2=690151&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java Fri Aug 29 01:37:42 2008
@@ -167,11 +167,13 @@
     }
     
     public void writeCompleted() throws IOException {
-        if (this.endOfStream) {
-            return;
+        synchronized (this.mutex) {
+            if (this.endOfStream) {
+                return;
+            }
+            this.endOfStream = true;
+            this.ioctrl.requestOutput();
         }
-        this.endOfStream = true;
-        this.ioctrl.requestOutput();
     }
     
 }