Attached is what I think may be an even more improved fix for 37356.
It does away with the accessCount which should make Remy happy.
It should prevent sessions currently in use from expiring which should
make those other 2 people and myself happy.
It doesn't add any synchronization but I believe it to be thread-safe
which should make speed people happy.

The negative is session expiration is now partially dependent on the
garbage collector.

The way it works is the StandardSessionFacade is referenced like it
was with the facade field in StandardSession and a WeakReference to
the StandardSessionFacade is added the the field facadeReference.
After the maxInactiveInterval the facade field is set to null. Next
time the garbage collector it should break the WeakReference and the
next time the StandardSession is checked to see if it is still valid,
it will be expired.

If there are any long running requests, they will maintain a "strong"
reference to the session facade preventing the standard session from
being expired.

If a request for the session comes in after the maxInactiveInterval
but before the WeakReference is broken the facade field will be
updated with the value of the weak reference to prevent the session
expiration.

The patch still needs a force session expire time in case a webapp
holds on to a session object after it's done processing a request. I
was thinking that could be 5 times the maxInactiveInterval value.

Is there any reason this solution isn't going to work that I'm not
aware of? I haven't done any long running test with this code yet
either. Patch is against the lastest svn as of this morning.

On 11/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: markt
Date: Sat Nov  4 17:11:11 2006
New Revision: 471309

URL: http://svn.apache.org/viewvc?view=rev&rev=471309
Log:
Improve fix for 37356.

Modified:
    
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/session/StandardSession.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/session/StandardSession.java
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/session/StandardSession.java?view=diff&rev=471309&r1=471308&r2=471309
==============================================================================
--- 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/session/StandardSession.java
 (original)
+++ 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/session/StandardSession.java
 Sat Nov  4 17:11:11 2006
@@ -612,8 +612,10 @@

         evaluateIfValid();

-        synchronized (lock) {
-            accessCount++;
+        if (Globals.STRICT_SERVLET_COMPLIANCE) {
+            synchronized (lock) {
+                accessCount++;
+            }
         }

     }
@@ -625,10 +627,12 @@
     public void endAccess() {

         isNew = false;
-        synchronized (lock) {
-            accessCount--;
+
+        if (Globals.STRICT_SERVLET_COMPLIANCE) {
+            synchronized (lock) {
+                accessCount--;
+            }
         }
-
     }



Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=471309&r1=471308&r2=471309
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Sat Nov  4 17:11:11 2006
@@ -62,7 +62,15 @@
         StandardWrapper. (markt)
       </fix>
       <fix>
-        <bug>37356</bug>: Ensure sessions time out correctly. (markt)
+        <bug>37356</bug>: Ensure sessions time out correctly. This has been
+        fixed by removing the accessCount feature by default. This feature
+        prevents the session from timing out whilst requests that last
+        longer than the session time out are being processed. This feature
+        is enabled by setting the Java option
+        <code>-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=true</code>
+        The feature is now implemented with synchronization which addresses
+        the thread safety issues associated with the original bug report.
+        (markt)
       </fix>
       <fix>
         <bug>40528</bug>: Add missing message localisations as provided by



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to