diff options
Diffstat (limited to 'zenstore/caslog.cpp')
| -rw-r--r-- | zenstore/caslog.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/zenstore/caslog.cpp b/zenstore/caslog.cpp index e080d6771..03a56f010 100644 --- a/zenstore/caslog.cpp +++ b/zenstore/caslog.cpp @@ -123,7 +123,7 @@ CasLogFile::GetLogSize() uint64_t CasLogFile::GetLogCount() { - uint64_t LogFileSize = m_File.FileSize(); + uint64_t LogFileSize = m_AppendOffset.load(std::memory_order_acquire); if (LogFileSize < sizeof(FileHeader)) { return 0; @@ -134,19 +134,22 @@ CasLogFile::GetLogCount() } void -CasLogFile::Replay(std::function<void(const void*)>&& Handler) +CasLogFile::Replay(std::function<void(const void*)>&& Handler, uint64_t SkipEntryCount) { uint64_t LogFileSize = m_File.FileSize(); // Ensure we end up on a clean boundary - const uint64_t LogBaseOffset = sizeof(FileHeader); - const size_t LogEntryCount = (LogFileSize - LogBaseOffset) / m_RecordSize; + uint64_t LogBaseOffset = sizeof(FileHeader); + size_t LogEntryCount = (LogFileSize - LogBaseOffset) / m_RecordSize; - if (LogEntryCount == 0) + if (LogEntryCount <= SkipEntryCount) { return; } + LogBaseOffset += SkipEntryCount * m_RecordSize; + LogEntryCount -= SkipEntryCount; + // This should really be streaming the data rather than just // reading it into memory, though we don't tend to get very // large logs so it may not matter |