craigmcc 01/04/24 19:20:49 Modified: catalina/src/share/org/apache/catalina/core LocalStrings.properties StandardWrapper.java Log: [PFD2-2.3.4] "Before the servlet container calls the destroy method, it must allow any threads that are currently running in the service method of the servlet to complete execution, or exceed a server defined time limit." Added a check on whether our (single) instance has been allocated, and wait for it to be deallocated before calling destroy(). Revision Changes Path 1.31 +2 -0 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- LocalStrings.properties 2001/04/15 10:45:28 1.30 +++ LocalStrings.properties 2001/04/25 02:20:48 1.31 @@ -282,6 +282,8 @@ standardWrapper.unloadException=Servlet {0} threw unload() exception +standardWrapper.unloading=Cannot allocate servlet {0} because it is being unloaded + http.100=The client may continue ({0}). http.101=The server is switching protocols according to the "Upgrade" header ({0}). 1.19 +36 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java Index: StandardWrapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- StandardWrapper.java 2001/04/07 22:33:01 1.18 +++ StandardWrapper.java 2001/04/25 02:20:48 1.19 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v 1.18 2001/04/07 22:33:01 remm Exp $ - * $Revision: 1.18 $ - * $Date: 2001/04/07 22:33:01 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v 1.19 2001/04/25 02:20:48 craigmcc Exp $ + * $Revision: 1.19 $ + * $Date: 2001/04/25 02:20:48 $ * * ==================================================================== * @@ -104,7 +104,7 @@ * make them efficient are counter-productive. * * @author Craig R. McClanahan - * @version $Revision: 1.18 $ $Date: 2001/04/07 22:33:01 $ + * @version $Revision: 1.19 $ $Date: 2001/04/25 02:20:48 $ */ public final class StandardWrapper @@ -221,6 +221,12 @@ private boolean singleThreadModel = false; + /** + * Are we unloading our servlet instance at the moment? + */ + private boolean unloading = false; + + // ------------------------------------------------------------- Properties @@ -577,6 +583,11 @@ if (debug >= 1) log("Allocating an instance"); + // If we are currently unloading this servlet, throw an exception + if (unloading) + throw new ServletException + (sm.getString("standardWrapper.unloading", getName())); + // Load and initialize our instance if necessary if (instance == null) { try { @@ -930,6 +941,25 @@ // Nothing to do if we have never loaded the instance if (instance == null) return; + unloading = true; + + // Loaf a while if the current instance is allocated + if (allocated) { + boolean first = true; + while (allocated) { + if (first) { + if (debug >= 1) + log("Waiting for instance to be deallocated"); + first = false; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + ; + } + } + } + // Call the servlet destroy() method try { @@ -943,6 +973,7 @@ (InstanceEvent.AFTER_DESTROY_EVENT, instance); instance = null; fireContainerEvent("unload", this); + unloading = false; throw new ServletException (sm.getString("standardWrapper.destroyException", getName()), t); @@ -951,6 +982,7 @@ // Deregister the destroyed instance instance = null; jasperLoader = null; + unloading = false; fireContainerEvent("unload", this); }