}
break;
+ case kBadRecordLen:
+ ReportCorruption(drop_size, "bad record length");
+ if (in_fragmented_record) {
+ ReportCorruption(scratch->size(), "error in middle of record");
+ in_fragmented_record = false;
+ scratch->clear();
+ }
+ break;
+
+ case kBadRecordChecksum:
+ ReportCorruption(drop_size, "checksum mismatch");
+ if (in_fragmented_record) {
+ ReportCorruption(scratch->size(), "error in middle of record");
+ in_fragmented_record = false;
+ scratch->clear();
+ }
+ break;
+
default: {
char buf[40];
snprintf(buf, sizeof(buf), "unknown record type %u", record_type);
*drop_size = buffer_.size();
buffer_.clear();
if (!eof_) {
- ReportCorruption(*drop_size, "bad record length");
- return kBadRecord;
+ return kBadRecordLen;
}
// If the end of the file has been reached without reading |length| bytes
// of payload, assume the writer died in the middle of writing the record.
// like a valid log record.
*drop_size = buffer_.size();
buffer_.clear();
- ReportCorruption(*drop_size, "checksum mismatch");
- return kBadRecord;
+ return kBadRecordChecksum;
}
}
kBadHeader = kMaxRecordType + 3,
// Returned when we read an old record from a previous user of the log.
kOldRecord = kMaxRecordType + 4,
+ // Returned when we get a bad record length
+ kBadRecordLen = kMaxRecordType + 5,
+ // Returned when we get a bad record checksum
+ kBadRecordChecksum = kMaxRecordType + 6,
};
// Skips all blocks that are completely before "initial_offset_".