Commit 67094207 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent eaa5832c
......@@ -411,6 +411,12 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
return make_pair(nil, E(err));
mem_stop = mem_start + blk_len*f.blksize;
bool retok = false;
defer([&]() {
if (!retok)
mm::unmap(mem_start, mem_stop - mem_start); // ignore error
});
if (stop > f._headfsize) {
uint8_t *zmem_start = mem_start + (max(f._headfsize/*XXX -1 ?*/, start) - start);
err = mmap_zero_into_ro(zmem_start, mem_stop - zmem_start);
......@@ -430,7 +436,9 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
zodb::Tid rev = _.second;
if (!(blk_start <= blk && blk < blk_stop))
continue; // blk out of this mapping
mmap->_remmapblk(blk, rev); // XXX err?
err = mmap->_remmapblk(blk, rev);
if (err != nil)
return make_pair(nil, E(err));
}
f._mmaps.push_back(mmap); // XXX keep f._mmaps ↑blk_start
......@@ -439,6 +447,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
vma->mmap_overlay_server = mmap._ptr(); // XXX +giveref
}
retok = true;
return make_pair(mmap, nil);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment