Commit 70803cff authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7355cffc
......@@ -322,13 +322,19 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
if (err != nil)
return make_pair(nil, E(err));
bool allok = false;
defer([&]() {
if (!allok)
f->_headf->close();
});
struct stat st;
err = f->_headf->stat(&st);
if (err != nil)
return make_pair(nil, E(err)); // XXX close headf
return make_pair(nil, E(err));
f->blksize = st.st_blksize;
f->_headfsize = st.st_size;
if (!(f->_headfsize % f->blksize == 0)) // XXX close headf
if (!(f->_headfsize % f->blksize == 0))
return make_pair(nil, E(fmt::errorf("wcfs bug: head/file size %% blksize != 0")));
wconn._filehtab[foid] = f;
......@@ -340,10 +346,10 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
return make_pair(nil, E(err));
if (ack != "ok") {
// XXX unregister f from _filehtab
// XXX close headf
return make_pair(nil, fmt::errorf("watch: %s", v(ack)));
}
allok = true;
return make_pair(f, 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