Author: markt Date: Fri Jul 4 00:25:22 2008 New Revision: 673933 URL: http://svn.apache.org/viewvc?rev=673933&view=rev Log: Another fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43683 This isn't perfect but it narrows the window for the race condition significantly. A perfect fix would require syncing most (all?) of allocate() which is on the critical path.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=673933&r1=673932&r2=673933&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Jul 4 00:25:22 2008 @@ -38,14 +38,6 @@ +1: markt, fhanik -1: -* Another fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43683 - This isn't perfect but it narrows the window for the race condition - significantly. A perfect fix would require syncing most (all?) of allocate() - which is on the critical path. - http://svn.apache.org/viewvc?rev=672397&view=rev - +1: markt, fhanik, remm - -1: - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=36155 Port the fix from the JK Connector to the AJP and APR Connectors http://svn.apache.org/viewvc?rev=672454&view=rev Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=673933&r1=673932&r2=673933&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardWrapper.java Fri Jul 4 00:25:22 2008 @@ -792,6 +792,8 @@ throw new ServletException (sm.getString("standardWrapper.unloading", getName())); + boolean newInstance = false; + // If not SingleThreadedModel, return the same instance every time if (!singleThreadModel) { @@ -804,6 +806,12 @@ log.debug("Allocating non-STM instance"); instance = loadServlet(); + // For non-STM, increment here to prevent a race + // condition with unload. Bug 43683, test case #3 + if (!singleThreadModel) { + newInstance = true; + countAllocated++; + } } catch (ServletException e) { throw e; } catch (Throwable e) { @@ -817,10 +825,13 @@ if (!singleThreadModel) { if (log.isTraceEnabled()) log.trace(" Returning non-STM instance"); - countAllocated++; + // For new instances, count will have been incremented at the + // time of creation + if (!newInstance) { + countAllocated++; + } return (instance); } - } synchronized (instancePool) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]