1
0
forked from GitHub/gf-core

make sure that changes in the database are always flushed

This commit is contained in:
krangelov
2021-08-05 20:05:29 +02:00
parent 2d3aac5aa1
commit 36e87668e0
6 changed files with 28 additions and 21 deletions

View File

@@ -309,6 +309,16 @@ DB::~DB() {
close(fd);
}
void DB::sync()
{
size_t size =
current_db->ms->top + size + sizeof(size_t);
int res = msync((void *) current_db->ms, size, MS_SYNC | MS_INVALIDATE);
if (res != 0)
throw std::system_error(errno, std::generic_category());
}
moffset DB::get_root_internal() {
return ms->root_offset;
}