Skip to content

Commit

Permalink
MappedFile: file is ::munmap(2)-ed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyaxt committed Dec 6, 2011
1 parent a3599a4 commit b5c5ea9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ptnk/partitionedpageio.cpp
Expand Up @@ -117,7 +117,24 @@ MappedFile::MappedFile(part_id_t partid, const char* filename, int fd, int prot)

MappedFile::~MappedFile()
{
/* NOP */
// unmap mmap(2)s
page_id_t prevEnd = 0;
for(Mapping* m = &m_mapFirst; m; m = m->next.get())
{
if(m->offset)
{
size_t len = (m->pgidEnd - prevEnd) * PTNK_PAGE_SIZE;
::munmap(m->offset, len);
}

prevEnd = m->pgidEnd;
}

// close file
if(m_fd > 0)
{
::close(m_fd);
}
}

MappedFile::Mapping*
Expand Down

0 comments on commit b5c5ea9

Please sign in to comment.