You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Larry Isaacs <La...@sas.com> on 2000/12/01 19:31:38 UTC

RE: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core C ontextManager.java

Hi Costin,

I was getting ready to ask about ContextManager getting stuck
during shutdown.  This patch keeps it from getting stuck, but
if the context was in "STATE_READY", then "shutdownContext( context )"
is called which sets the state to "STATE_DISABLED" causing
removeContext() to exit early.  The interceptor's removeContext()
methods won't be called.  

While pondering a fix for this, I was also pondering what should
happen if an interceptor throws an exceptions during context
removal.  Currently, an exception would get handled outside
of ContextManger and potentially leave a context in an inconsistent
state.  Should interceptor exceptions be caught, logged, then
ignored by ContextManager so shutdown can proceed without being
aborted?

Also, it seems to me that a Tomcat shutdown will remove the contexts
out from under any requests that are currently using it.  Am I
missing something?  If not, should we try to add, or at least
provide for, an "orderly" shutdown in addition to the "forced"
shutdown we seem to currently have?

Cheers,
Larry





> -----Original Message-----
> From: costin@locus.apache.org [mailto:costin@locus.apache.org]
> Sent: Friday, December 01, 2000 12:43 PM
> To: jakarta-tomcat-cvs@apache.org
> Subject: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core
> ContextManager.java
> 
> 
> costin      00/12/01 09:42:52
> 
>   Modified:    src/share/org/apache/tomcat/core ContextManager.java
>   Log:
>   Fixed small bug that prevented normal shutdown.
>   
>   Revision  Changes    Path
>   1.152     +2 -1      
> jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
>   
>   Index: ContextManager.java
>   ===================================================================
>   RCS file: 
> /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Cont
> extManager.java,v
>   retrieving revision 1.151
>   retrieving revision 1.152
>   diff -u -r1.151 -r1.152
>   --- ContextManager.java	2000/11/30 06:17:12	1.151
>   +++ ContextManager.java	2000/12/01 17:42:51	1.152
>   @@ -494,6 +494,8 @@
>    	if( context.getState() == Context.STATE_READY )
>    	    shutdownContext( context );
>    
>   +	contextsV.removeElement(context);
>   +
>    	if( context.getState() == Context.STATE_DISABLED )
>    	    return;
>    	
>   @@ -505,7 +507,6 @@
>    	    cI[i].removeContext( this, context );
>    	}
>    
>   -	contextsV.removeElement(context);
>        }
>    
>    
>   
>   
>   
> 

RE: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core C ontextManager.java

Posted by cm...@yahoo.com.
Hi Larry,

> during shutdown.  This patch keeps it from getting stuck, but
> if the context was in "STATE_READY", then "shutdownContext( context )"
> is called which sets the state to "STATE_DISABLED" causing
> removeContext() to exit early.  The interceptor's removeContext()
> methods won't be called.  

I fixed that - but I'm not sure what's the right order: 
should we 
add -> init -> shutdown -> remove 
or
init-> add -> remove -> shutdown ?

The second seems much better ( the context may be initialized but not in
use, for example if an admin wants to temporarily disable a context)

All the "context state" is new in 3.3 - for 3.2 it just happens to works (
because we fixed everything to work in most cases, without a clear
definition ). 


> While pondering a fix for this, I was also pondering what should
> happen if an interceptor throws an exceptions during context
> removal.  Currently, an exception would get handled outside
> of ContextManger and potentially leave a context in an inconsistent
> state.  Should interceptor exceptions be caught, logged, then
> ignored by ContextManager so shutdown can proceed without being
> aborted?

Yes, you are right - I'll fix this. 

Should it be the case for all context callbacks ? I think engineInit
exceptions should be propagated ( and the server shouldn't start after
that). Probably the same for contextAdd/contextInit - if any exception
happens, the context will be disabled.

I agree that shutdown errors should be ignored ( logged only ).

> Also, it seems to me that a Tomcat shutdown will remove the contexts
> out from under any requests that are currently using it.  Am I
> missing something?  If not, should we try to add, or at least
> provide for, an "orderly" shutdown in addition to the "forced"
> shutdown we seem to currently have?

I was thinking that this should be done in an interceptor - shutdown can
wait until all requests for that context are done ( with a timeout ). It
would be nice to have this.

Costin