Author: markt Date: Tue Jul 14 17:22:47 2009 New Revision: 793981 URL: http://svn.apache.org/viewvc?rev=793981&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=40380 Correct synchronisation of expire() Should now only run one per session
Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=793981&r1=793980&r2=793981&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original) +++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Tue Jul 14 17:22:47 2009 @@ -162,7 +162,7 @@ * certain IllegalStateException tests. NOTE: This value is not * included in the serialized version of this object. */ - protected transient boolean expiring = false; + protected transient volatile boolean expiring = false; /** @@ -220,7 +220,7 @@ /** * Flag indicating whether this session is valid or not. */ - protected boolean isValid = false; + protected volatile boolean isValid = false; /** @@ -683,15 +683,20 @@ */ public void expire(boolean notify) { - // Mark this session as "being expired" if needed - if (expiring) + // Check to see if expire is in progress or has previously been called + if (expiring || !isValid) return; synchronized (this) { + // Check again, now we are inside the sync so this code only runs once + // Double check locking - expiring and isValid need to be volatile + if (expiring || !isValid) + return; if (manager == null) return; + // Mark this session as "being expired" expiring = true; // Notify interested application event listeners --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org