activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1335600 - /activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala
Date Tue, 08 May 2012 15:54:54 GMT
Author: chirino
Date: Tue May  8 15:54:54 2012
New Revision: 1335600

URL: http://svn.apache.org/viewvc?rev=1335600&view=rev
Log:
Avoid a potential race condition.

Modified:
    activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala?rev=1335600&r1=1335599&r2=1335600&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/RecordLog.scala
Tue May  8 15:54:54 2012
@@ -174,11 +174,12 @@ case class RecordLog(directory: File, lo
 //        // Directly write the data to the channel since it's large.
 //        val buffer = data.toByteBuffer
 //        val pos = append_offset + LOG_HEADER_SIZE
-//        flushed_offset.addAndGet(buffer.remaining)
+//        val remaining = buffer.remaining
 //        channel.write(buffer, pos)
 //        if (buffer.hasRemaining) {
 //          throw new IOException("Short write")
 //        }
+//        flushed_offset.addAndGet(remaining)
 //        append_offset += data_length
 //
 //      } else {
@@ -198,12 +199,13 @@ case class RecordLog(directory: File, lo
     def flush = this.synchronized {
       if (write_buffer.position() > 0) {
         val buffer = write_buffer.toBuffer.toByteBuffer
-        val pos = append_offset - buffer.remaining
-        flushed_offset.addAndGet(buffer.remaining)
+        val remaining = buffer.remaining
+        val pos = append_offset - remaining
         channel.write(buffer, pos)
         if (buffer.hasRemaining) {
           throw new IOException("Short write")
         }
+        flushed_offset.addAndGet(remaining)
         write_buffer.reset()
       }
     }



Mime
View raw message