[jboss-cvs] JBoss Messaging SVN: r7143 - branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun May 31 17:16:35 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-05-31 17:16:34 -0400 (Sun, 31 May 2009)
New Revision: 7143
Modified:
branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
Log:
fixes on the journal
Modified: branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-05-31 04:19:37 UTC (rev 7142)
+++ branches/Branch_JBM2_Perf_Clebert/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java 2009-05-31 21:16:34 UTC (rev 7143)
@@ -748,6 +748,20 @@
return maxID;
}
+ private boolean isInvalidSize(int bufferPos, int size)
+ {
+ if (size < 0)
+ {
+ return true;
+ }
+ else
+ {
+ final int position = bufferPos + size;
+ return position > fileSize || position < 0;
+
+ }
+ }
+
/**
* <p>Load data accordingly to the record layouts</p>
*
@@ -843,7 +857,7 @@
continue;
}
- if (wholeFileBuffer.position() + SIZE_INT > fileSize)
+ if (isInvalidSize(wholeFileBuffer.position(), SIZE_INT))
{
// II - Ignore this record, lets keep looking
continue;
@@ -857,7 +871,7 @@
if (isTransaction(recordType))
{
- if (wholeFileBuffer.position() + SIZE_LONG > fileSize)
+ if (isInvalidSize(wholeFileBuffer.position(), SIZE_LONG))
{
continue;
}
@@ -869,7 +883,7 @@
if (!isCompleteTransaction(recordType))
{
- if (wholeFileBuffer.position() + SIZE_LONG > fileSize)
+ if (isInvalidSize(wholeFileBuffer.position(), SIZE_LONG))
{
continue;
}
@@ -895,21 +909,16 @@
if (isContainsBody(recordType))
{
- if (wholeFileBuffer.position() + SIZE_INT > fileSize)
+ if (isInvalidSize(wholeFileBuffer.position(), SIZE_INT))
{
continue;
}
variableSize = wholeFileBuffer.getInt();
- if (wholeFileBuffer.position() + variableSize > fileSize)
+ if (isInvalidSize(wholeFileBuffer.position(), variableSize))
{
- log.warn("Record at position " + pos +
- " type = " +
- recordType +
- " file:" +
- file.getFile().getFileName() +
- " is corrupted and it is being ignored");
+ wholeFileBuffer.position(pos + 1);
continue;
}
@@ -940,11 +949,11 @@
// VI - this is completing V, We will validate the size at the end
// of the record,
// But we avoid buffer overflows by damaged data
- if (pos + recordSize + variableSize + preparedTransactionExtraDataSize > fileSize)
+ if (isInvalidSize(pos, recordSize + variableSize + preparedTransactionExtraDataSize))
{
// Avoid a buffer overflow caused by damaged data... continue
// scanning for more records...
- log.warn("Record at position " + pos +
+ log.debug("Record at position " + pos +
" recordType = " +
recordType +
" file:" +
@@ -969,7 +978,7 @@
// checkSize by some sort of calculated hash)
if (checkSize != variableSize + recordSize + preparedTransactionExtraDataSize)
{
- log.warn("Record at position " + pos +
+ log.debug("Record at position " + pos +
" recordType = " +
recordType +
" file:" +
@@ -1643,9 +1652,6 @@
sf.setBuffering(false);
sf.open(1);
-
- // TODO: we should try to avoid reinitializing a file
- sf.fill(0, fileSize, FILL_CHARACTER);
ByteBuffer bb = fileFactory.newBuffer(SIZE_INT);
More information about the jboss-cvs-commits
mailing list