Commit 39f1bd67 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 02fa982f
......@@ -168,9 +168,11 @@ def _pinner(wconn, ctx):
f.pinned[req.blk] = req.at
# mmap creates file mapping representing file data as of wconn.at database state.
# mmap creates file mapping representing file[blk_start +blk_len) data as of wconn.at database state.
@func(Conn)
def mmap(wconn, foid, blk, blklen): # -> Mapping
def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
assert blk_len >= 0
blk_stop = blk_start + blk_len
with wconn._filemu:
f = wconn._filetab.get(foid)
if f is None:
......@@ -186,8 +188,11 @@ def mmap(wconn, foid, blk, blklen): # -> Mapping
# XXX relock wconn -> f ?
# create memory with head/f mapping and applied pins
mem = mm.map_ro(f.headf.fileno(), blk*f.blksize, blklen*f.blksize)
mmap = _Mapping(f, blk_start, mem)
mem = mm.map_ro(f.headf.fileno(), blk_start*f.blksize, blk_len*f.blksize)
mmap = _Mapping()
mmap.file = f
mmap.blk_start = blk_start
mmap.mem = mem
for blk, rev in f.pinned.items(): # XXX keep f.pinned ↑blk and use binary search?
if not (blk_start <= blk < blk_stop):
continue # blk out of this mapping
......
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