Author: markt
Date: Tue Jul 29 09:30:39 2014
New Revision: 1614292

URL: http://svn.apache.org/r1614292
Log:
Workaroud https://issues.apache.org/bugzilla/show_bug.cgi?id=56684
Don't shutdown if shutdown port experiences a SocketTimeoutException

Modified:
    tomcat/tc6.0.x/trunk/   (props changed)
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc6.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1608963,1609061
  Merged /tomcat/tc7.0.x/trunk:r1609079

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1614292&r1=1614291&r2=1614292&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Jul 29 09:30:39 2014
@@ -51,12 +51,6 @@ PATCHES PROPOSED TO BACKPORT:
   +1: kkolinko
   -1:
 
-* Workaroud https://issues.apache.org/bugzilla/show_bug.cgi?id=56684
-  Don't shutdown if shutdown port experiences a SocketTimeoutException
-  http://svn.apache.org/r1609079
-  +1: markt, kkolinko, schultz
-  -1:
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56661
   Support using AJP request attribute AJP_LOCAL_ADDR to fix getLocalAddr().
   Backport of r1609593 from trunk resp. r1609606 from tc7.

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1614292&r1=1614291&r2=1614292&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties 
Tue Jul 29 09:30:39 2014
@@ -197,6 +197,7 @@ standardServer.initialize.initialized=Th
 standardServer.start.connectors=At least one connector is not associated with 
any container
 standardServer.start.started=This server has already been started
 standardServer.stop.notStarted=This server has not yet been started
+standardServer.accept.timeout=The socket listening for the shutdown command 
experienced an unexpected timeout [{0}] milliseconds after the call to 
accept(). Is this an instance of bug 56684?
 standardService.connector.initFailed=Failed to initialize connector [{0}]
 standardService.connector.pauseFailed=Failed to pause connector [{0}]
 standardService.connector.startFailed=Failed to start connector [{0}]

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardServer.java?rev=1614292&r1=1614291&r2=1614292&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardServer.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardServer.java Tue 
Jul 29 09:30:39 2014
@@ -5,20 +5,17 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.catalina.core;
 
-
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.IOException;
@@ -26,6 +23,7 @@ import java.io.InputStream;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.SocketTimeoutException;
 import java.security.AccessControlException;
 import java.util.Random;
 
@@ -59,10 +57,10 @@ import org.apache.tomcat.util.modeler.Re
  *
  */
 public final class StandardServer
-    implements Lifecycle, Server, MBeanRegistration 
+    implements Lifecycle, Server, MBeanRegistration
  {
     private static Log log = LogFactory.getLog(StandardServer.class);
-   
+
 
     // -------------------------------------------------------------- Constants
 
@@ -376,7 +374,7 @@ public final class StandardServer
 
     /**
      * Wait until a proper shutdown command is received, then return.
-     * This keeps the main thread alive - the thread pool listening for http 
+     * This keeps the main thread alive - the thread pool listening for http
      * connections is daemon threads.
      */
     public void await() {
@@ -421,16 +419,23 @@ public final class StandardServer
                 if (serverSocket == null) {
                     break;
                 }
-    
+
                 // Wait for the next connection
                 Socket socket = null;
                 StringBuilder command = new StringBuilder();
                 try {
                     InputStream stream = null;
+                    long acceptStartTime = System.currentTimeMillis();
                     try {
                         socket = serverSocket.accept();
                         socket.setSoTimeout(10 * 1000);  // Ten seconds
                         stream = socket.getInputStream();
+                    } catch (SocketTimeoutException ste) {
+                        // This should never happen but bug 56684 suggests that
+                        // it does.
+                        log.warn(sm.getString("standardServer.accept.timeout",
+                                Long.valueOf(System.currentTimeMillis() - 
acceptStartTime)), ste);
+                        continue;
                     } catch (AccessControlException ace) {
                         log.warn("StandardServer.accept security exception: "
                                            + ace.getMessage(), ace);
@@ -531,8 +536,8 @@ public final class StandardServer
         return (services);
 
     }
-    
-    /** 
+
+    /**
      * Return the JMX service names.
      */
     public ObjectName[] getServiceNames() {
@@ -638,7 +643,7 @@ public final class StandardServer
      */
     public synchronized void storeConfig() throws Exception {
         ObjectName sname = new ObjectName("Catalina:type=StoreConfig");
-        mserver.invoke(sname, "storeConfig", null, null);            
+        mserver.invoke(sname, "storeConfig", null, null);
     }
 
 
@@ -654,20 +659,20 @@ public final class StandardServer
      *  by the persistence mechanism
      */
     public synchronized void storeContext(Context context) throws Exception {
-        
-        ObjectName sname = null;    
+
+        ObjectName sname = null;
         try {
            sname = new ObjectName("Catalina:type=StoreConfig");
            if(mserver.isRegistered(sname)) {
                mserver.invoke(sname, "store",
-                   new Object[] {context}, 
+                   new Object[] {context},
                    new String [] { "java.lang.String"});
            } else
                log.error("StoreConfig mbean not registered" + sname);
         } catch (Throwable t) {
             log.error(t);
         }
- 
+
     }
 
 
@@ -798,13 +803,13 @@ public final class StandardServer
     public void init() throws Exception {
         initialize();
     }
-    
+
     /**
      * Invoke a pre-startup initialization. This is used to allow connectors
      * to bind to restricted ports under Unix operating environments.
      */
     public void initialize()
-        throws LifecycleException 
+        throws LifecycleException
     {
         if (initialized) {
                 
log.info(sm.getString("standardServer.initialize.initialized"));
@@ -822,10 +827,10 @@ public final class StandardServer
                 log.error("Error registering ",e);
             }
         }
-        
+
         // Register global String cache
         try {
-            ObjectName oname2 = 
+            ObjectName oname2 =
                 new ObjectName(oname.getDomain() + ":type=StringCache");
             Registry.getRegistry(null, null)
                 .registerComponent(new StringCache(), oname2, null );
@@ -838,7 +843,7 @@ public final class StandardServer
             services[i].initialize();
         }
     }
-    
+
     protected String type;
     protected String domain;
     protected String suffix;
@@ -869,5 +874,5 @@ public final class StandardServer
 
     public void postDeregister() {
     }
-    
+
 }

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1614292&r1=1614291&r2=1614292&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Jul 29 09:30:39 2014
@@ -55,6 +55,11 @@
        a container (e.g. adding a Context to a Host) to prevent blocking
        requests to other children while the new child starts. (markt)
       </fix>
+      <fix>
+        <bug>56684</bug>: Ensure that Tomcat does not shut down if the socket
+        waiting for the shutdown command experiences a
+        <code>SocketTimeoutException</code>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to