tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1660609 - in /tomcat/trunk/java/org/apache/coyote/http11/upgrade: UpgradeProcessor.java UpgradeServletOutputStream.java
Date Wed, 18 Feb 2015 12:14:24 GMT
Author: markt
Date: Wed Feb 18 12:14:24 2015
New Revision: 1660609

URL: http://svn.apache.org/r1660609
Log:
registered is guarded by registeredLock so there is no need for it to be volatile.
Simplify the process of triggering the first call to onWritePossible

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java?rev=1660609&r1=1660608&r2=1660609&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeProcessor.java Wed Feb 18 12:14:24
2015
@@ -99,7 +99,6 @@ public class UpgradeProcessor implements
     public final SocketState upgradeDispatch(SocketStatus status) {
         if (status == SocketStatus.OPEN_READ) {
             upgradeServletInputStream.onDataAvailable();
-            upgradeServletOutputStream.checkWriteDispatch();
         } else if (status == SocketStatus.OPEN_WRITE) {
             upgradeServletOutputStream.onWritePossible();
         } else if (status == SocketStatus.STOP) {

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=1660609&r1=1660608&r2=1660609&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/UpgradeServletOutputStream.java Wed
Feb 18 12:14:24 2015
@@ -55,12 +55,7 @@ public class UpgradeServletOutputStream
     private volatile WriteListener listener = null;
 
     // Guarded by registeredLock
-    private volatile boolean registered = false;
-
-    // Use to track if a dispatch needs to be arranged to trigger the first call
-    // to onWritePossible. If the socket gets registered for write while this is
-    // set then this will be ignored.
-    private volatile boolean writeDispatchRequired = false;
+    private boolean registered = false;
 
     private volatile ClassLoader applicationLoader = null;
 
@@ -110,7 +105,10 @@ public class UpgradeServletOutputStream
         }
         // Container is responsible for first call to onWritePossible() but only
         // need to do this if setting the listener for the first time.
-        writeDispatchRequired = true;
+        synchronized (registeredLock) {
+            registered = true;
+            socketWrapper.addDispatch(DispatchType.NON_BLOCKING_WRITE);
+        }
 
         this.listener = listener;
         this.applicationLoader = Thread.currentThread().getContextClassLoader();
@@ -265,16 +263,4 @@ public class UpgradeServletOutputStream
             }
         }
     }
-
-
-    void checkWriteDispatch() {
-        synchronized (registeredLock) {
-            if (writeDispatchRequired) {
-                writeDispatchRequired = false;
-                if (!registered) {
-                    socketWrapper.addDispatch(DispatchType.NON_BLOCKING_WRITE);
-                }
-            }
-        }
-    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message