Commit 20c301bc authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ce13601e
......@@ -116,7 +116,7 @@ struct Conn {
public:
error close();
void resync(Tid at);
error resync(Tid at);
private:
void _pinner(IContext *ctx);
......@@ -365,8 +365,9 @@ void Conn::_pin1(PinReq *req) {
// XXX Conn::mmap
// resync resyncs connection and its mappings onto different database view.
void Conn::resync(Tid at) { // XXX void -> err?
error Conn::resync(Tid at) {
Conn &wconn = *this;
// XXX err ctx
// XXX locking
......@@ -378,9 +379,10 @@ void Conn::resync(Tid at) { // XXX void -> err?
// 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
struct stat st;
auto err = f->headf.stat(&st) // XXX err
assert f.blksize == st.st_blksize // blksize must not change
headfsize = st.st_size;
assert f.headfsize <= headfsize // head/file size ↑=
assert headfsize % f.blksize == 0
for mmap in f.mmaps:
......@@ -393,11 +395,12 @@ void Conn::resync(Tid at) { // XXX void -> err?
f.headfsize = headfsize;
_ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at)))
if _ != "ok":
_ = wconn._wlink->sendReq(context.background(), fmt::sprintf("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;
......
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