jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk AbstractDiskCache.java
Date Wed, 14 Apr 2004 17:06:12 GMT
asmuts      2004/04/14 10:06:12

  Modified:    src/java/org/apache/jcs/utils/locking ReadWriteLock.java
               src/java/org/apache/jcs/auxiliary/disk/indexed
                        IndexedDiskCache.java
               src/java/org/apache/jcs/auxiliary/disk
                        AbstractDiskCache.java
  Log:
  It should be safe to dispose now.  Kill queue, optimize, then play dead.
  
  Fixed a problem in the ReadWriteLock class that let the number of writelocks get below zero.
 This seems to have solved many problems.  However, I can't find out why there are more done
calls than lock calls.   Added a break into the wait on the readlock in case noone calls notify.
  
  This may have fixed the mysterious locking problem that I've never been able to duplicate.
  
  Revision  Changes    Path
  1.3       +14 -3     jakarta-turbine-jcs/src/java/org/apache/jcs/utils/locking/ReadWriteLock.java
  
  Index: ReadWriteLock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/utils/locking/ReadWriteLock.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReadWriteLock.java	22 Aug 2003 11:57:19 -0000	1.2
  +++ ReadWriteLock.java	14 Apr 2004 17:06:12 -0000	1.3
  @@ -117,7 +117,7 @@
           while ( writeLockedThread != null )
           {
               log.debug( "readLock wait" );
  -            wait();
  +            wait(20);
               log.debug( "wake up from readLock wait" );
           }
   
  @@ -211,9 +211,20 @@
               }
               return;
           }
  +
           if ( Thread.currentThread() == writeLockedThread )
           {
  -            outstandingWriteLocks--;
  +
  +            //log.info( "outstandingWriteLocks= " + outstandingWriteLocks );
  +            if ( outstandingWriteLocks > 0 )
  +            {
  +                outstandingWriteLocks--;
  +            }
  +            else
  +            {
  +                log.warn( "extra lock release, writelocks are " + outstandingWriteLocks
+ "and done was called" );
  +            }
  +
               if ( outstandingWriteLocks > 0 )
               {
                   log.debug( "writeLock released for a nested writeLock request." );
  @@ -243,7 +254,7 @@
                   if ( waitingForReadLock > 0 )
                   {
                       log.debug( "writeLock released, notified waiting readers" );
  -                    
  +
                       notifyAll();
                   }
                   else
  
  
  
  1.9       +18 -2     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
  
  Index: IndexedDiskCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IndexedDiskCache.java	14 Apr 2004 06:24:18 -0000	1.8
  +++ IndexedDiskCache.java	14 Apr 2004 17:06:12 -0000	1.9
  @@ -300,6 +300,7 @@
               {
                   storageLock.done();
               }
  +
               if ( log.isDebugEnabled() )
               {
                   log.debug( "Put to file: " + fileName +
  @@ -469,8 +470,15 @@
               }
               else
               {
  +
  +                if ( log.isDebugEnabled() )
  +                {
  +                    log.debug( "Disk removal: Removed from key hash, key " + key );
  +                }
  +
                   // remove single item.
                   return keyHash.remove( key ) != null;
  +
               }
           }
           catch ( Exception e )
  @@ -588,7 +596,14 @@
           finally
           {
               alive = false;
  -            storageLock.done();
  +
  +            try
  +            {
  +              storageLock.done();
  +            } catch ( Exception e )
  +            {
  +                log.error( "Failure releasing lock on shutdown " + e );
  +            }
           }
       }
   
  @@ -673,6 +688,7 @@
                       log.debug( fileName + " -- newData.length() = " +
                           newData.length() );
                   }
  +
                   newData.renameTo( newFileName );
               }
               keyHash = keyHashTemp;
  
  
  
  1.19      +4 -6      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
  
  Index: AbstractDiskCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractDiskCache.java	14 Apr 2004 06:24:18 -0000	1.18
  +++ AbstractDiskCache.java	14 Apr 2004 17:06:12 -0000	1.19
  @@ -300,13 +300,11 @@
       public final void dispose()
       {
   
  -        // Invoke any implementation specific disposal code
  -
  -        doDispose();
  -
           // FIXME: May lose the end of the queue, need to be more graceful
  -
           cacheEventQueue.destroy();
  +
  +        // Invoke any implementation specific disposal code
  +        doDispose();
   
           alive = false;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org


Mime
View raw message