tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <>
Subject Strange 1000 seconds timeout in AprEndpoint
Date Mon, 25 May 2015 05:26:38 GMT
When testing tcnative I observed a strange 1000 seconds timeout. The 
occurrence of the timeout was likely due to using an old OpenSSL version 
(0.9.8m) in combination with the unit tests that want a newer one, but I 
found the long duration of 1000 seconds strange.

It happens in TestSsl.testSimpleSsl lines 66 and again in line 86 (TC8):

25-May-2015 00:30:27.121 SEVERE [main] 
org.apache.coyote.AbstractProtocol.init Failed to initialize end point 
associated with ProtocolHandler ["http-apr-"]
  java.lang.Exception: Unable to create SSLContext. Check that SSLEngine 
is enabled in the AprLifecycleListener, the AprLifecycleListener has 
initialised correctly and that a valid SSLProtocol has been specified

As a consequence the handshakes hangs:

Testcase: testSimpleSsl took 1,006.091 sec
         Caused an ERROR
Read timed out Read timed out
         at Method)

I did a little svn archaelogy and I think the problem goes back to 
revision r1433976 in AprEndpoint where the following code block

-                    // Check timeouts (much less frequently than polling)
-                    if (maintainTime > 1000000L && running) {
-                        maintainTime = 0;
-                        if (socketProperties.getSoTimeout() > 0) {
-                            doTimeout(connectionPollset);
-                        }
-                    }

changed into

+                    // Process socket timeouts
+                    if (getSoTimeout() > 0 && maintain++ > 1000 &&

running) {
+                        // This works and uses only one timeout 
mechanism for everything, but the
+                        // non event poller might be a bit faster by 
using the old maintain.
+                        maintain = 0;
+                        maintain();

The commit contains many more changes, but I think the problem can be 
localized in this block. In APR maintainTime is in microseconds (it is 
incremented with pollTime which is in microseconds), so 1000000L is one 
second. The new block counts maintain and I think that is incremented 
once per second, so we switch from a 1000000 microsecond = 1 second 
condition to a 1000 second condition.

I'm not sure whether it is better to simply check for maintain++ > 1 (or 
 >= 1) or switch back to summing up pollTime.Needs more investigation.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message