You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Peter Rossbach <pr...@objektpark.de> on 2007/10/07 10:35:00 UTC

Call stopAwait at StandardServer.stop

Hi,

I have reviewed Catalina and StandardServer Tomcat 6 implementation.  
I can see that the old trick with <Server port="-1" ... doesn´t work  
correct. The main thread is not terminate after a stop signal was  
received.

With port=-1 setting a user can start a tomcat without opening a  
shutdown port.  Ok, the only chance to stop a tomcat instance
is to send a signal to the jvm process, but the stopAwait flag at  
StandardServer doesn't trigger.

Catalina.stop ...
         // Shut down the server
         if (server instanceof Lifecycle) {
             try {
                 ((Lifecycle) server).stop();
             } catch (LifecycleException e) {
                 log.error("Catalina.stop", e);
             }
         }

calls only StandardServer stop, but stop doesn't trigger the  
stopAwait flag

     public void stop() throws LifecycleException {

         // Validate and update our current component state
         if (!started)
             return;

         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

         lifecycle.fireLifecycleEvent(STOP_EVENT, null);
         started = false;

         // Stop our defined Services
         for (int i = 0; i < services.length; i++) {
             if (services[i] instanceof Lifecycle)
                 ((Lifecycle) services[i]).stop();
         }

         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);

     }

can we please fix it:

     public void stop() throws LifecycleException {

         // Validate and update our current component state
         if (!started)
             return;

         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

         lifecycle.fireLifecycleEvent(STOP_EVENT, null);
         started = false;

         // Stop our defined Services
         for (int i = 0; i < services.length; i++) {
             if (services[i] instanceof Lifecycle)
                 ((Lifecycle) services[i]).stop();
         }
	// ====== FIX BEGIN
	if(port == -1)
		stopAwait() ;
        // ====== END
         // Notify our interested LifecycleListeners
         lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);

     }

I think we can also backport it to Tomcat 5.5 trunk

regards
Peter




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


Re: Call stopAwait at StandardServer.stop

Posted by Remy Maucherat <re...@apache.org>.
Peter Rossbach wrote:
> can we please fix it:
> 
>     public void stop() throws LifecycleException {
> 
>         // Validate and update our current component state
>         if (!started)
>             return;
> 
>         // Notify our interested LifecycleListeners
>         lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
> 
>         lifecycle.fireLifecycleEvent(STOP_EVENT, null);
>         started = false;
> 
>         // Stop our defined Services
>         for (int i = 0; i < services.length; i++) {
>             if (services[i] instanceof Lifecycle)
>                 ((Lifecycle) services[i]).stop();
>         }
>     // ====== FIX BEGIN
>     if(port == -1)
>         stopAwait() ;
>        // ====== END
>         // Notify our interested LifecycleListeners
>         lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
> 
>     }
> 
> I think we can also backport it to Tomcat 5.5 trunk

I was not aware of this feature. The change is ok, but I think the sleep 
time of the thread should also be reduced when the port is -1.

Rémy

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