Author: markt
Date: Fri Oct  1 14:54:53 2010
New Revision: 1003550

URL: http://svn.apache.org/viewvc?rev=1003550&view=rev
Log:
https://issues.apache.org/bugzilla/show_bug.cgi?id=49890
Detect when the JVM bug occurs and log an error asking for more information.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
    tomcat/trunk/webapps/docs/changelog.xml

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=1003550&r1=1003549&r2=1003550&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Fri Oct  1 
14:54:53 2010
@@ -937,6 +937,9 @@ public class NioEndpoint extends Abstrac
         
         protected volatile int keyCount = 0;
 
+        private static final int JVM_BUG_THRESHOLD = 16;
+        private volatile int jvmBugCount = 0; 
+        
         public Poller() throws IOException {
             this.selector = Selector.open();
         }
@@ -1088,7 +1091,17 @@ public class NioEndpoint extends Abstrac
                             }else {
                                 keyCount = selector.keys().size();
                                 wakeupCounter.set(-1);
+                                long before = System.currentTimeMillis();
                                 keyCount = selector.select(selectorTimeout);
+                                long after = System.currentTimeMillis();
+                                if (keyCount == 0 &&
+                                        (after - before) < selectorTimeout/2) {
+                                    jvmBugCount++;
+                                    if (jvmBugCount > JVM_BUG_THRESHOLD) {
+                                        log.error(sm.getString(
+                                                "endpoint.err.jvmbug"));
+                                    }
+                                }
                             }
                             wakeupCounter.set(0);
                         }

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties?rev=1003550&r1=1003549&r2=1003550&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 
Fri Oct  1 14:54:53 2010
@@ -42,3 +42,5 @@ endpoint.sendfile.error=Unexpected sendf
 endpoint.sendfile.addfail=Sendfile failure: [{0}] {1}
 endpoint.sendfile.nosupport=Disabling sendfile, since either the APR version 
or the system doesn't support it
 endpoint.warn.noInsecureReneg=Secure renegotation is not supported by the SSL 
library {0}
+endpoint.err.jvmbug=The poller for the NIO connector may have entered an error 
state triggered by a JVM bug. See bug 49890 for more information. If you see 
this message with a 1.6.0u18 or later JVM and a 2.6 or later kernel please 
update the Tomcat bug with exact version information.
+  
\ No newline at end of file

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1003550&r1=1003549&r2=1003550&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Oct  1 14:54:53 2010
@@ -59,7 +59,7 @@
       <fix>
         <bug>49209</bug>: Prevent possible AccessControlException during
         undeployment when running with a security manager. Patch provided by
-        Sylvain Laurent.
+        Sylvain Laurent. (markt)
       </fix>
       <fix>
         <bug>49657</bug>: Handle CGI executables with spaces in the path.
@@ -239,6 +239,12 @@
         <bug>49860</bug>: Add support for trailing headers in chunked HTTP
         requests. (markt)
       </fix>
+      <add>
+        <bug>49890</bug>: Detect when NIO connector encounters a known JVM bug
+        on Linux and log an error to help determine if the bug is still present
+        ort not. The JVM bug should be fixed for 2.6 kernels and the 1.6.0u18
+        JVMs and later. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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

Reply via email to