kief 01/04/10 06:00:31 Modified: catalina/src/share/org/apache/catalina/session PersistentManager.java Log: Applied patch from Bip Thelin <[EMAIL PROTECTED]> A little update to PersistentManager.java to backup sessions that's been Idle for longer than specified max time. Revision Changes Path 1.4 +37 -9 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManager.java Index: PersistentManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PersistentManager.java 2001/04/07 10:25:03 1.3 +++ PersistentManager.java 2001/04/10 13:00:30 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManager.java,v 1.3 2001/04/07 10:25:03 kief Exp $ - * $Revision: 1.3 $ - * $Date: 2001/04/07 10:25:03 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManager.java,v 1.4 2001/04/10 13:00:30 kief Exp $ + * $Revision: 1.4 $ + * $Date: 2001/04/10 13:00:30 $ * * ==================================================================== * @@ -106,7 +106,7 @@ * <li>Limit the number of active sessions kept in memory by * swapping less active sessions out to disk.</li> * - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @author Kief Morris ([EMAIL PROTECTED]) */ @@ -782,7 +782,33 @@ if (!started || maxIdleBackup < 0) return; - // FIXME: Do something useful + Session sessions[] = findSessions(); + long timeNow = System.currentTimeMillis(); + + // Back up all sessions idle longer than maxIdleBackup + if (maxIdleBackup >= 0) { + for (int i = 0; i < sessions.length; i++) { + StandardSession session = (StandardSession) sessions[i]; + if (!session.isValid()) + continue; + int timeIdle = // Truncate, do not round up + (int) ((timeNow - session.getLastAccessedTime()) / 1000L); + if (timeIdle > maxIdleBackup) { + if (debug > 1) + log(sm.getString + ("persistentManager.backupMaxIdle", + session.getId(), new Integer(timeIdle))); + + try { + backup(session); + } catch (IOException e) { + log(sm.getString + ("persistentManager.backupException", session.getId(), e)); + } + } + } + } + } @@ -862,9 +888,11 @@ * Write the session out to Store, but leave the copy in * the Manager's memory unmodified. */ - private void backup() throws IOException { + private void backup(Session session) throws IOException { - // FIXME: Do something + if (!session.isValid() + || isSessionStale(session, System.currentTimeMillis())) + return; } @@ -873,11 +901,11 @@ * Read the session in from Store, overriding the copy in * the Manager's memory. */ - private void recover() throws IOException { +// private void recover() throws IOException { // FIXME: Do something - } +// } /**