tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <>
Subject Re: Bug Report - 4.1.27 Race Condition
Date Mon, 11 Aug 2003 16:41:21 GMT
Wesley Hall wrote:
> Hello,
> I have found a small bug during my work embedding the tomcat server into our
> application.
> When a secure connector is added to an instance of Embedded, and embedded is
> startd and stopped several times in quick succession (which is part of our
> test framework) a race condition occurs.
> Sometimes i am presented with an exception with a root cause of...
> Caused by: LifecycleException: Coyote connector has not been started
> at org.apache.coyote.tomcat4.CoyoteConnector.stop(
> at org.apache.catalina.startup.Embedded.stop(
> (NOTE: This exception is thrown after a call to the start method of Embedded
> has been made and connectors added)
> Other times the test is successful. Sometimes (although a little more rare
> than these two outcomes), I recieve an 'Address already in use', which seems
> to be the inverse of the exception above, and occurs on a call to start()
> after a stop() has already been made.
> Placing a Thread.sleep(x) between start/stop attempts seems to increase the
> likelyhood of the test being successful and increasing the interval increase
> the percentage of successful test runs until upon reaching an interval of
> 75ms the success rate becomes 100%.

Unless there's a major unexpected flaw and I missed something, I do 
believe that the shutdown is synchronous if you use the stop method 
(using the shutdown socket is not synchronous, but it's another 
problem). That means that something, somehwere, is being shutdown 
asynchronously related to SSL, be it at the OS level or at the JDK 
level. Given that SSL uses a non trivial amount of resources, which also 
take a significant amount of time to allocate, I'm not completely 
surprised by what you see.

As your next paragraph states, it would be useful to double check in the 
Tomcat code, but I don't expect you would find much. I believe it's 
rather straightforward code.

IMO, you should make a quick pass looking for an obvious flaw, then go 
with a 100ms delay. Unless you have to restart the embedded TC every 2s, 
I think it should be acceptable.

> It seems there is a race condition in starting up or shutting down of
> Embedded vs The secure connector. Sometimes Embedded.start() will return
> before the connector has been started and the same with Embedded.stop().
> Unfortunatly, i cannot seem to locate the Coyote source to verify this.

It's part of the source distribution, in the j-t-connectors directory.

> Presumably, this issue is pretty minor as the only circumstance i can see
> where someone will be running stops and starts in quick succession is a
> contrived test case, but i thought i would bring it to your attention
> anyway.


View raw message