Commit 272e43bd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 60dacc49
...@@ -77,7 +77,7 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset); ...@@ -77,7 +77,7 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset);
// connect creates new Conn viewing WCFS state as of @at. // connect creates new Conn viewing WCFS state as of @at.
pair<Conn, error> WCFS::connect(zodb::Tid at) { pair<Conn, error> WCFS::connect(zodb::Tid at) {
WCFS *wc = this; WCFS *wc = this;
// XXX errctx "connect @%s", at xerr::Contextf E("connect @%s", v(at)); // XXX +wc path?
// TODO support !isolated mode // TODO support !isolated mode
...@@ -85,7 +85,7 @@ pair<Conn, error> WCFS::connect(zodb::Tid at) { ...@@ -85,7 +85,7 @@ pair<Conn, error> WCFS::connect(zodb::Tid at) {
error err; error err;
tie(wlink, err) = wc->_openwatch(); tie(wlink, err) = wc->_openwatch();
if (err != nil) if (err != nil)
return make_pair(nil, err); return make_pair(nil, E(err));
Conn wconn = adoptref(new _Conn()); Conn wconn = adoptref(new _Conn());
wconn->_wc = wc; wconn->_wc = wc;
...@@ -108,8 +108,10 @@ pair<Conn, error> WCFS::connect(zodb::Tid at) { ...@@ -108,8 +108,10 @@ pair<Conn, error> WCFS::connect(zodb::Tid at) {
// XXX what happens to file mmappings? // XXX what happens to file mmappings?
error _Conn::close() { error _Conn::close() {
_Conn& wconn = *this; _Conn& wconn = *this;
// XXX errctx "close conn @%s", wconn.at //xerr::Contextf E("close conn @%s", v(wconn.at));
xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at));
// XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself? // XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself?
error err, eret; error err, eret;
auto reterr1 = [&eret](error err) { auto reterr1 = [&eret](error err) {
if (eret == nil && err != nil) if (eret == nil && err != nil)
...@@ -122,7 +124,7 @@ error _Conn::close() { ...@@ -122,7 +124,7 @@ error _Conn::close() {
wconn._pinCancel(); wconn._pinCancel();
err = wconn._pinWG->wait(); err = wconn._pinWG->wait();
if (err != context::canceled) // canceled - ok if (err != context::canceled) // canceled - ok
reterr1(err); reterr1(fmt::errorf("pinwg.wait: %s", v(err))); // XXX remove errctx
// close all files - both that have no mappings and that still have opened mappings. // close all files - both that have no mappings and that still have opened mappings.
// XXX after file is closed mappings continue to survive, but we can no // XXX after file is closed mappings continue to survive, but we can no
...@@ -145,11 +147,7 @@ error _Conn::close() { ...@@ -145,11 +147,7 @@ error _Conn::close() {
wconn._filehtab.clear(); wconn._filehtab.clear();
// XXX -> try to xerr.Contextf at top return E(eret);
if (eret != nil)
eret = fmt::errorf("close conn @%s: %s", v(wconn.at), v(eret));
return eret;
} }
// _pinner receives pin messages from wcfs and adjusts wconn mappings. // _pinner receives pin messages from wcfs and adjusts wconn mappings.
...@@ -196,7 +194,7 @@ void _Conn::_pin1(PinReq *req) { ...@@ -196,7 +194,7 @@ void _Conn::_pin1(PinReq *req) {
// reply either ack or nak on error // reply either ack or nak on error
string ack = "ack"; string ack = "ack";
if (err != nil) if (err != nil)
ack = fmt::sprintf("nak: %s", err->Error().c_str()); ack = fmt::sprintf("nak: %s", v(err));
wconn._wlink->replyReq(context::background(), req, ack); // XXX ctx ok? wconn._wlink->replyReq(context::background(), req, ack); // XXX ctx ok?
} }
...@@ -259,7 +257,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -259,7 +257,7 @@ error _Conn::__pin1(PinReq *req) {
pair<FileH, error> _Conn::open(zodb::Oid foid) { pair<FileH, error> _Conn::open(zodb::Oid foid) {
_Conn& wconn = *this; _Conn& wconn = *this;
error err; error err;
// XXX err ctx xerr::Contextf E("conn @%s: open f<%s>", v(wconn.at), v(foid));
wconn._filehmu.lock(); wconn._filehmu.lock();
defer([&]() { defer([&]() {
...@@ -281,16 +279,16 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -281,16 +279,16 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
tie(f->_headf, err) tie(f->_headf, err)
= wconn._wc->_open(fmt::sprintf("head/bigfile/%s", v(foid))); = wconn._wc->_open(fmt::sprintf("head/bigfile/%s", v(foid)));
if (err != nil) if (err != nil)
return make_pair(nil, err); return make_pair(nil, E(err));
struct stat st; struct stat st;
err = f->_headf->stat(&st); err = f->_headf->stat(&st);
if (err != nil) if (err != nil)
return make_pair(nil, err); return make_pair(nil, E(err)); // XXX close headf
f->blksize = st.st_blksize; f->blksize = st.st_blksize;
f->_headfsize = st.st_size; f->_headfsize = st.st_size;
if (!(f->_headfsize % f->blksize == 0)) if (!(f->_headfsize % f->blksize == 0)) // XXX close headf
return make_pair(nil, fmt::errorf("wcfs bug: head/file size %% blksize != 0")); return make_pair(nil, E(fmt::errorf("wcfs bug: head/file size %% blksize != 0")));
wconn._filehtab[foid] = f; wconn._filehtab[foid] = f;
...@@ -298,11 +296,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -298,11 +296,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
string ack; string ack;
tie(ack, err) = wconn._wlink->sendReq(context::background(), fmt::sprintf("watch %s @%s", v(foid), v(wconn.at))); tie(ack, err) = wconn._wlink->sendReq(context::background(), fmt::sprintf("watch %s @%s", v(foid), v(wconn.at)));
if (err != nil) if (err != nil)
return make_pair(nil, err); return make_pair(nil, E(err));
if (ack != "ok") { if (ack != "ok") {
// XXX unregister f from _filehtab // XXX unregister f from _filehtab
// XXX vvv -> errctx? // XXX close headf
return make_pair(nil, fmt::errorf("@%s: open f<%s>: watch: %s", v(wconn.at), v(foid), ack.c_str())); return make_pair(nil, fmt::errorf("watch: %s", v(ack)));
} }
return make_pair(f, nil); return make_pair(f, nil);
...@@ -431,7 +429,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -431,7 +429,7 @@ error _Conn::resync(zodb::Tid at) {
if (ack != "ok") { if (ack != "ok") {
// XXX unregister f from _filehtab // XXX unregister f from _filehtab
// XXX vvv -> errctx? // XXX vvv -> errctx?
return fmt::errorf("resync @%s -> @%s: f<%s>: %s", v(wconn.at), v(at), v(foid), ack.c_str()); return fmt::errorf("resync @%s -> @%s: f<%s>: %s", v(wconn.at), v(at), v(foid), v(ack));
} }
} }
......
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