directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1195128 - in /directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log: DefaultLogScanner.java LogFlushManager.java LogManager.java
Date Sun, 30 Oct 2011 07:55:16 GMT
Author: saya
Date: Sun Oct 30 07:55:16 2011
New Revision: 1195128

URL: http://svn.apache.org/viewvc?rev=1195128&view=rev
Log:
fixed checksum related issues:
*cheksum was not computed for the case user buffer was larger than the internal log buffer
*checksump update updates the current checksum with the given data. To make the computed checksum
predicatable, we need to call reset() on the checksum before computing the new checksum.

Modified:
    directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogScanner.java
    directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
    directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogManager.java

Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogScanner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogScanner.java?rev=1195128&r1=1195127&r2=1195128&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogScanner.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogScanner.java
Sun Oct 30 07:55:16 2011
@@ -177,6 +177,7 @@ public class DefaultLogScanner implement
             readLogRecord( logRecord, recordLength - ( LogFileRecords.RECORD_HEADER_SIZE
+ LogFileRecords.RECORD_FOOTER_SIZE ));
             
             // Read and verify footer
+            checksum.reset();
             checksum.update( logRecord.getDataBuffer(), 0, logRecord.getDataLength() );
             readRecordFooter( (int)checksum.getValue() );
             

Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java?rev=1195128&r1=1195127&r2=1195128&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
Sun Oct 30 07:55:16 2011
@@ -137,6 +137,11 @@ import org.apache.directory.server.i18n.
         {
             lsn = logLSN++;
             
+            
+            // Compute the checksum for the user record
+            checksum.reset();
+            checksum.update( userBuffer, 0, length );
+            
             if ( currentLogFile == null )
             {
                 // We are just starting, get the current log file
@@ -177,8 +182,7 @@ import org.apache.directory.server.i18n.
                             // Write the data
                             writeHead.put( userBuffer, 0, length );
                             
-                            // Compute the checksum and write the footer
-                            checksum.update( userBuffer, 0, length );
+                            // Write the footeer
                             writeFooter( writeHead, (int)checksum.getValue() );
                             
                             appendedRecord = true;
@@ -212,8 +216,7 @@ import org.apache.directory.server.i18n.
                             // Write the data
                             writeHead.put( userBuffer, 0, length );
 
-                            // Compute the checksum and write the footer
-                            checksum.update( userBuffer, 0, length );
+                            // Write the footer
                             writeFooter( writeHead, (int)checksum.getValue() );
 
                             appendedRecord = true;
@@ -386,7 +389,7 @@ import org.apache.directory.server.i18n.
                 currentLogFile.append( userBuffer, offset, length );   
                 
                 headerFooterHead.rewind();
-                writeFooter( headerFooterHead, 0 );
+                writeFooter( headerFooterHead, (int)checksum.getValue() );
                 currentLogFile.append( logBuffer.headerFooterBuffer, 0, LogFileRecords.RECORD_FOOTER_SIZE
);
     
                 flushedLSN = flushLSN;

Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogManager.java?rev=1195128&r1=1195127&r2=1195128&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogManager.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogManager.java
Sun Oct 30 07:55:16 2011
@@ -361,6 +361,7 @@ import org.apache.directory.server.i18n.
         controlFileMarker.putLong( controlFileRecord.minNeededLSN );
         
         // Compute the checksum
+        checksum.reset();
         checksum.update( controlFileMarker.array(), 0, CONTROLFILE_CHECKSUM_SIZE );
         controlFileRecord.checksum = checksum.getValue();
         
@@ -424,6 +425,7 @@ import org.apache.directory.server.i18n.
         controlFileRecord.checksum = controlFileMarker.getLong();
         int magicNumber = controlFileMarker.getInt();
         
+        checksum.reset();
         checksum.update( controlFileMarker.array(), 0, CONTROLFILE_CHECKSUM_SIZE );
         
         if ( ( controlFileRecord.minExistingLogFile < LogAnchor.MIN_LOG_NUMBER ) ||



Mime
View raw message