Commit 594e0684 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7cbb1b4a
...@@ -88,40 +88,6 @@ class WCFS(_WCFS): ...@@ -88,40 +88,6 @@ class WCFS(_WCFS):
pass pass
""" """
# resync resyncs connection and its mappings onto different database view.
@func(Conn)
def resync(wconn, at):
# XXX locking
for foid, f in wconn._filetab.items():
# XXX if file has no mappings and was not used during whole prev
# cycle - forget and stop watching it
# update f.headfsize and remmap to head/f zero regions that are now covered by head/f
_ = os.fstat(f.headf.fileno())
assert f.blksize == _.st_blksize # blksize must not change
headfsize = _.st_size
assert f.headfsize <= headfsize # head/file size ↑=
assert headfsize % f.blksize == 0
for mmap in f.mmaps:
print(' resync -> %s: unzero [%d:%d)' % (at, f.headfsize//f.blksize, headfsize//f.blksize))
memunzero = mmap.mem[f.headfsize - mmap.blk_start*f.blksize :
headfsize - mmap.blk_start*f.blksize]
if len(memunzero) > 0:
mm.map_into_ro(memunzero, f.headf.fileno(), f.headfsize)
f.headfsize = headfsize
_ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at)))
if _ != "ok":
# XXX unregister f from _filetab
# XXX vvv -> errctx?
raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _))
wconn.at = at
# _remmapblk remmaps mapping memory for file[blk] to be viewing database as of @at state. # _remmapblk remmaps mapping memory for file[blk] to be viewing database as of @at state.
# #
# at=None means unpin to head/ . # at=None means unpin to head/ .
......
...@@ -362,7 +362,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -362,7 +362,7 @@ error _Conn::resync(zodb::Tid at) {
// update f.headfsize and remmap to head/f zero regions that are now covered by head/f // update f.headfsize and remmap to head/f zero regions that are now covered by head/f
struct stat st; struct stat st;
auto err = f.headf->stat(&st); error err = f.headf->stat(&st);
if (err != nil) if (err != nil)
return err; return err;
......
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