Skip to content

Commit

Permalink
Make sure to zero-fill the page in PostReadPage()
Browse files Browse the repository at this point in the history
  • Loading branch information
extratype committed Dec 9, 2021
1 parent 389896f commit 5aee954
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,12 +1989,23 @@ DWORD ChunkDiskWorker::PostReadPage(ChunkOpState& state)
if (err != ERROR_NOT_FOUND)
{
// page hit or error
if (h != INVALID_HANDLE_VALUE) CloseChunkAsync(chunk_idx, false);
if (h != INVALID_HANDLE_VALUE)
{
CloseChunkAsync(chunk_idx, false);
}
else if (err == ERROR_SUCCESS)
{
memset(ptr, 0, service_.bases[0].PageBytes(1));
}
return err;
}

// page miss
if (h == INVALID_HANDLE_VALUE) return ERROR_SUCCESS;
if (h == INVALID_HANDLE_VALUE)
{
// page already zero-filled
return ERROR_SUCCESS;
}

const auto length_bytes = u32(service_.bases[0].PageBytes(1));
auto bytes_read = DWORD();
Expand Down Expand Up @@ -2022,7 +2033,6 @@ DWORD ChunkDiskWorker::PostReadPage(ChunkOpState& state)
if (state.kind != WRITE_PAGE_PARTIAL)
{
// page hit, chunk not found or empty
// page already zero-filled
auto& base = service_.bases[0];
auto length_bytes = base.BlockBytes(state.end_off - state.start_off);
memcpy(state.buffer, recast<u8*>(ptr) + base.BlockBytes(state.start_off), length_bytes);
Expand Down

0 comments on commit 5aee954

Please sign in to comment.