billbarker 02/04/04 21:39:08 Modified: util/java/org/apache/tomcat/util/threads Expirer.java Log: Improve the Thread-safety on the 3.3 Session exipiration. I was seeing every so often that a brand-new session was getting expired. With this we take a snap-shot of the sessions so that we don't have to worry about the data changing under our feet while we're doing the checking. By keeping the array as part of the Object, we should avoid excess GC as well. Revision Changes Path 1.2 +10 -2 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/Expirer.java Index: Expirer.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/Expirer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Expirer.java 6 Jan 2002 08:34:56 -0000 1.1 +++ Expirer.java 5 Apr 2002 05:39:08 -0000 1.2 @@ -99,6 +99,7 @@ // -------------------- Managed objects -------------------- static final int INITIAL_SIZE=8; TimeStamp managedObjs[]=new TimeStamp[INITIAL_SIZE]; + TimeStamp checkedObjs[]=new TimeStamp[INITIAL_SIZE]; int managedLen=managedObjs.length; int managedCount=0; @@ -159,8 +160,15 @@ public void runIt( Object td[] ) { long timeNow = System.currentTimeMillis(); if( dL > 2 ) debug( "Checking " + timeNow ); - for( int i=0; i< managedCount; i++ ) { - TimeStamp ts=managedObjs[i]; + int checkedCount; + synchronized( managedObjs ) { + checkedCount=managedCount; + if(checkedObjs.length < checkedCount) + checkedObjs = new TimeStamp[managedLen]; + System.arraycopy( managedObjs, 0, checkedObjs, 0, checkedCount); + } + for( int i=0; i< checkedCount; i++ ) { + TimeStamp ts=checkedObjs[i]; if (ts==null || !ts.isValid()) continue;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>