hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r508510 - /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
Date Fri, 16 Feb 2007 17:36:21 GMT
Author: olegk
Date: Fri Feb 16 09:36:19 2007
New Revision: 508510

URL: http://svn.apache.org/viewvc?view=rev&rev=508510
Log:
Added extra sync point to ensure the connection is ready to transmit an HTTP response

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?view=diff&rev=508510&r1=508509&r2=508510
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
Fri Feb 16 09:36:19 2007
@@ -487,6 +487,28 @@
             final ServerConnState connState,
             final ContentIOControl ioControl) throws IOException, HttpException {
 
+        // Make sure the connection is ready for output
+        // (the previous worker thread terminated)
+        synchronized (connState) {
+            try {
+                for (;;) {
+                    int currentState = connState.getOutputState();
+                    if (currentState == ServerConnState.READY) {
+                        break;
+                    }
+                    if (currentState == ServerConnState.SHUTDOWN) {
+                        break;
+                    }
+                    connState.wait();
+                }
+            } catch (InterruptedException ex) {
+                connState.shutdown();
+            }
+            if (connState.getOutputState() == ServerConnState.SHUTDOWN) {
+                return;
+            }
+        }
+        
         // Response is ready to be committed
         HttpResponse response = connState.getResponse();
         
@@ -512,7 +534,10 @@
             try {
                 for (;;) {
                     int currentState = connState.getOutputState();
-                    if (currentState == expectedSate || currentState == ServerConnState.SHUTDOWN)
{
+                    if (currentState == expectedSate) {
+                        break;
+                    }
+                    if (currentState == ServerConnState.SHUTDOWN) {
                         break;
                     }
                     connState.wait();



Mime
View raw message