Author: markt
Date: Fri Feb 27 15:02:07 2015
New Revision: 1662717
URL: http://svn.apache.org/r1662717
Log:
No need to force write processing onto a separate thread
Modified:
tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java
Modified:
tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java?rev=1662717&r1=1662716&r2=1662717&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java
(original)
+++
tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java
Fri Feb 27 15:02:07 2015
@@ -21,9 +21,11 @@ import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
+import org.apache.coyote.ContainerThreadMarker;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.net.DispatchType;
import org.apache.tomcat.util.net.SocketWrapperBase;
import org.apache.tomcat.util.res.StringManager;
@@ -111,15 +113,12 @@ public class UpgradeServletOutputStream
// Container is responsible for first call to onWritePossible().
synchronized (registeredLock) {
registered = true;
- // Need to get writes onto a separate thread as long as WebSocket
- // uses Servlet non-blocking I/O as onOpen can throw an error which
- // closes the WebSocket connection. That uses a blocking write
which
- // means onwWritePossible needs to be on a separate thread to clear
- // the latch used in the blocking write. If
- // socketWrapper.addDispatch() was used the current thread would
- // block on the write and would not process the dispatch until the
- // latch timed out triggering more errors.
- socketWrapper.registerWriteInterest();
+ // Container is responsible for first call to onDataAvailable().
+ if (ContainerThreadMarker.isContainerThread()) {
+ socketWrapper.addDispatch(DispatchType.NON_BLOCKING_WRITE);
+ } else {
+ socketWrapper.registerWriteInterest();
+ }
}
this.listener = listener;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]