craigmcc 01/08/15 19:46:52
Modified: catalina/src/share/org/apache/catalina/core
StandardWrapper.java
Log:
Do not allow an unload() operation to begin if there are any current
requests executing within this servlet. This fixes a potential race
condition if an context reload occurs while active requests to one or more
servlets are still occurring.
Revision Changes Path
1.28 +32 -8
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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- StandardWrapper.java 2001/07/25 04:05:50 1.27
+++ StandardWrapper.java 2001/08/16 02:46:52 1.28
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.27 2001/07/25 04:05:50 remm Exp $
- * $Revision: 1.27 $
- * $Date: 2001/07/25 04:05:50 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
1.28 2001/08/16 02:46:52 craigmcc Exp $
+ * $Revision: 1.28 $
+ * $Date: 2001/08/16 02:46:52 $
*
* ====================================================================
*
@@ -105,7 +105,7 @@
* make them efficient are counter-productive.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.27 $ $Date: 2001/07/25 04:05:50 $
+ * @version $Revision: 1.28 $ $Date: 2001/08/16 02:46:52 $
*/
public final class StandardWrapper
@@ -146,6 +146,13 @@
/**
+ * The count of allocations that are currently active (even if they
+ * are for the same instance, as will be true on a non-STM servlet).
+ */
+ private int countAllocated = 0;
+
+
+ /**
* The debugging detail level for this component.
*/
private int debug = 0;
@@ -273,6 +280,18 @@
/**
+ * Return the number of active allocations of this servlet, even if they
+ * are all for the same instance (as will be true for servlets that do
+ * not implement <code>SingleThreadModel</code>.
+ */
+ public int getCountAllocated() {
+
+ return (this.countAllocated);
+
+ }
+
+
+ /**
* Return the debugging detail level for this component.
*/
public int getDebug() {
@@ -612,6 +631,7 @@
if (!singleThreadModel) {
if (debug >= 2)
log(" Returning non-STM instance");
+ countAllocated++;
return (instance);
}
@@ -629,6 +649,7 @@
if (debug >= 2)
log(" Returning allocated STM instance");
allocated = true;
+ countAllocated++;
return (instance);
}
@@ -646,6 +667,8 @@
*/
public void deallocate(Servlet servlet) throws ServletException {
+ countAllocated--;
+
// If not SingleThreadModel, no action is required
if (!singleThreadModel)
return;
@@ -963,12 +986,13 @@
unloading = true;
// Loaf a while if the current instance is allocated
- if (allocated) {
+ // (possibly more than once if non-STM)
+ if (countAllocated > 0) {
boolean first = true;
- while (allocated) {
+ while (countAllocated > 0) {
if (first) {
- if (debug >= 1)
- log("Waiting for instance to be deallocated");
+ log("Waiting for " + countAllocated +
+ " instance(s) to be deallocated");
first = false;
}
try {