Fix case B in bug 43343. Don't try to swap out a session that is being accessed.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 25 May 2009 22:32:57 +0000 (22:32 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 25 May 2009 22:32:57 +0000 (22:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@778524 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/PersistentManagerBase.java

index c2b5c42..67ab712 100644 (file)
@@ -1054,6 +1054,12 @@ public abstract class PersistentManagerBase
                     int timeIdle = // Truncate, do not round up
                         (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
                     if (timeIdle > maxIdleSwap && timeIdle > minIdleSwap) {
+                        if (sessions[i] instanceof StandardSession) {
+                            if (((StandardSession) sessions[i]).accessCount.get() > 0) {
+                                // Session is currently being accessed - skip it
+                                continue;
+                            }
+                        }                       
                         if (log.isDebugEnabled())
                             log.debug(sm.getString
                                 ("persistentManager.swapMaxIdle",
@@ -1098,6 +1104,12 @@ public abstract class PersistentManagerBase
                 int timeIdle = // Truncate, do not round up
                     (int) ((timeNow - sessions[i].getThisAccessedTime()) / 1000L);
                 if (timeIdle > minIdleSwap) {
+                    if (sessions[i] instanceof StandardSession) {
+                        if (((StandardSession) sessions[i]).accessCount.get() > 0) {
+                            // Session is currently being accessed - skip it
+                            continue;
+                        }
+                    }
                     if(log.isDebugEnabled())
                         log.debug(sm.getString
                             ("persistentManager.swapTooManyActive",