tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1502304 - in /tomcat/trunk/java/org/apache: coyote/http11/upgrade/ tomcat/util/net/
Date Thu, 11 Jul 2013 18:08:17 GMT
Author: markt
Date: Thu Jul 11 18:08:17 2013
New Revision: 1502304

URL: http://svn.apache.org/r1502304
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55240
Prevent looping after Poller stop and ensure that streams for upgraded connections are closed
if possible.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/BioProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/NioProcessor.java
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java Thu Jul 11 18:08:17
2013
@@ -26,6 +26,7 @@ import javax.servlet.http.WebConnection;
 
 import org.apache.coyote.Processor;
 import org.apache.coyote.Request;
+import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.SSLSupport;
 import org.apache.tomcat.util.net.SocketStatus;
@@ -37,6 +38,7 @@ public abstract class AbstractProcessor<
 
     protected static final StringManager sm =
             StringManager.getManager(Constants.Package);
+    protected abstract Log getLog();
 
     private final HttpUpgradeHandler httpUpgradeHandler;
     private final AbstractServletInputStream upgradeServletInputStream;
@@ -93,6 +95,20 @@ public abstract class AbstractProcessor<
             upgradeServletInputStream.onDataAvailable();
         } else if (status == SocketStatus.OPEN_WRITE) {
             upgradeServletOutputStream.onWritePossible();
+        } else if (status == SocketStatus.STOP) {
+            try {
+                upgradeServletInputStream.close();
+            } catch (IOException ioe) {
+                getLog().debug(sm.getString(
+                        "abstractProcessor.isCloseFail", ioe));
+            }
+            try {
+                upgradeServletOutputStream.close();
+            } catch (IOException ioe) {
+                getLog().debug(sm.getString(
+                        "abstractProcessor.osCloseFail", ioe));
+            }
+            return SocketState.CLOSED;
         } else {
             // Unexpected state
             return SocketState.CLOSED;

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/AprProcessor.java?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/AprProcessor.java Thu Jul 11 18:08:17
2013
@@ -18,12 +18,18 @@ package org.apache.coyote.http11.upgrade
 
 import javax.servlet.http.HttpUpgradeHandler;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.jni.Socket;
 import org.apache.tomcat.util.net.AprEndpoint;
 import org.apache.tomcat.util.net.SocketWrapper;
 
 public class AprProcessor extends AbstractProcessor<Long> {
 
+    private static final Log log = LogFactory.getLog(AprProcessor.class);
+    @Override
+    protected Log getLog() {return log;}
+
     private static final int INFINITE_TIMEOUT = -1;
 
     public AprProcessor(SocketWrapper<Long> wrapper,

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/BioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/BioProcessor.java?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/BioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/BioProcessor.java Thu Jul 11 18:08:17
2013
@@ -21,10 +21,16 @@ import java.net.Socket;
 
 import javax.servlet.http.HttpUpgradeHandler;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.net.SocketWrapper;
 
 public class BioProcessor extends AbstractProcessor<Socket> {
 
+    private static final Log log = LogFactory.getLog(BioProcessor.class);
+    @Override
+    protected Log getLog() {return log;}
+
     private static final int INFINITE_TIMEOUT = 0;
 
     public BioProcessor(SocketWrapper<Socket> wrapper,

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/LocalStrings.properties Thu Jul 11
18:08:17 2013
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+abstractProcessor.isCloseFail=Failed to close input stream associated with upgraded connection
+abstractProcessor.osCloseFail=Failed to close output stream associated with upgraded connection
+
 upgrade.sis.isFinished.ise=It is illegal to call isFinished() when the ServletInputStream
is not in non-blocking mode (i.e. setReadListener() must be called first)
 upgrade.sis.isReady.ise=It is illegal to call isReady() when the ServletInputStream is not
in non-blocking mode (i.e. setReadListener() must be called first)
 upgrade.sis.readListener.null=It is illegal to pass null to setReadListener()

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/NioProcessor.java?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/NioProcessor.java Thu Jul 11 18:08:17
2013
@@ -18,12 +18,18 @@ package org.apache.coyote.http11.upgrade
 
 import javax.servlet.http.HttpUpgradeHandler;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioSelectorPool;
 import org.apache.tomcat.util.net.SocketWrapper;
 
 public class NioProcessor extends AbstractProcessor<NioChannel> {
 
+    private static final Log log = LogFactory.getLog(NioProcessor.class);
+    @Override
+    protected Log getLog() {return log;}
+
     private static final int INFINITE_TIMEOUT = -1;
 
     public NioProcessor(SocketWrapper<NioChannel> wrapper,

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1502304&r1=1502303&r2=1502304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Thu Jul 11 18:08:17 2013
@@ -1552,7 +1552,10 @@ public class NioEndpoint extends Abstrac
 
                 try {
                     if (key != null) {
-                        if (socket.isHandshakeComplete()) {
+                        // For STOP there is no point trying to handshake as the
+                        // Poller has been stopped.
+                        if (socket.isHandshakeComplete() ||
+                                status == SocketStatus.STOP) {
                             handshake = 0;
                         } else {
                             handshake = socket.handshake(
@@ -1576,8 +1579,6 @@ public class NioEndpoint extends Abstrac
                 if ( handshake == 0 ) {
                     SocketState state = SocketState.OPEN;
                     // Process the request from this socket
-                    // Suppress null warnings for key in this block since
-                    // key can't be null in this block
                     if (status == null) {
                         state = handler.process(ka, SocketStatus.OPEN_READ);
                     } else {



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


Mime
View raw message