Commit ce13601e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2b17189e
...@@ -114,7 +114,9 @@ struct Conn { ...@@ -114,7 +114,9 @@ struct Conn {
sync::Mutex _filemu; sync::Mutex _filemu;
dict<Oid, _File*> _filetab; // {} foid -> _file dict<Oid, _File*> _filetab; // {} foid -> _file
public:
error close(); error close();
void resync(Tid at);
private: private:
void _pinner(IContext *ctx); void _pinner(IContext *ctx);
...@@ -368,7 +370,10 @@ void Conn::resync(Tid at) { // XXX void -> err? ...@@ -368,7 +370,10 @@ void Conn::resync(Tid at) { // XXX void -> err?
// XXX locking // XXX locking
for foid, f in wconn._filetab.items(): for (auto _ : wconn._filetab) {
Oid foid = _.first;
_File *f = _.second;
// XXX if file has no mappings and was not used during whole prev // XXX if file has no mappings and was not used during whole prev
// cycle - forget and stop watching it // cycle - forget and stop watching it
...@@ -379,13 +384,13 @@ void Conn::resync(Tid at) { // XXX void -> err? ...@@ -379,13 +384,13 @@ void Conn::resync(Tid at) { // XXX void -> err?
assert f.headfsize <= headfsize // head/file size ↑= assert f.headfsize <= headfsize // head/file size ↑=
assert headfsize % f.blksize == 0 assert headfsize % f.blksize == 0
for mmap in f.mmaps: for mmap in f.mmaps:
print(' resync -> %s: unzero [%d:%d)' % (at, f.headfsize//f.blksize, headfsize//f.blksize)) printf(" resync -> %s: unzero [%d:%d)" % (at, f.headfsize//f.blksize, headfsize//f.blksize));
memunzero = mmap.mem[f.headfsize - mmap.blk_start*f.blksize : memunzero = mmap.mem[f.headfsize - mmap.blk_start*f.blksize :
headfsize - mmap.blk_start*f.blksize] headfsize - mmap.blk_start*f.blksize]
if len(memunzero) > 0: if len(memunzero) > 0:
mm.map_into_ro(memunzero, f.headf.fileno(), f.headfsize) mm.map_into_ro(memunzero, f.headf.fileno(), f.headfsize)
f.headfsize = headfsize f.headfsize = headfsize;
_ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at))) _ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at)))
...@@ -393,8 +398,9 @@ void Conn::resync(Tid at) { // XXX void -> err? ...@@ -393,8 +398,9 @@ void Conn::resync(Tid at) { // XXX void -> err?
// XXX unregister f from _filetab // XXX unregister f from _filetab
// XXX vvv -> errctx? // XXX vvv -> errctx?
raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _)) raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _))
}
wconn.at = at 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.
......
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