Commit f077ed67 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d55fddd6
...@@ -149,7 +149,6 @@ error _Conn::close() { ...@@ -149,7 +149,6 @@ error _Conn::close() {
if (!errors::Is(err, context::canceled)) // canceled - ok if (!errors::Is(err, context::canceled)) // canceled - ok
reterr1(err); reterr1(err);
// pinner is stopped - now close all files - both that have no mappings and // pinner is stopped - now close all files - both that have no mappings and
// that still have opened mappings. // that still have opened mappings.
// //
...@@ -194,9 +193,9 @@ error _Conn::_pinner(context::Context ctx) { ...@@ -194,9 +193,9 @@ error _Conn::_pinner(context::Context ctx) {
} }
// mark the connection non-operational if the pinner fails // mark the connection non-operational if the pinner fails
wconn._mu.lock(); // XXX locking ok? -> merge into below where lock is held? XXX + atMu.R ? wconn._mu.lock(); // XXX locking ok? -> merge into below where lock is held?
if (wconn._downErr == nil) { if (wconn._downErr == nil) {
wconn._downErr = fmt::errorf("no longer operational due to: %w", err); wconn._downErr = fmt::errorf("no longer operational due to: %w", err); // XXX err=nil ?
// XXX make all fileh and mapping invalid. // XXX make all fileh and mapping invalid.
} }
wconn._mu.unlock(); wconn._mu.unlock();
...@@ -335,10 +334,13 @@ error _Conn::__pin1(PinReq *req) { ...@@ -335,10 +334,13 @@ 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;
xerr::Contextf E("%s: open f<%s>", v(wconn), v(foid));
// XXX wconn._atMu.RLock() wconn._atMu.RLock();
// XXX defer wconn._atMu.RUnlock() defer([&]() {
wconn._atMu.RUnlock();
});
xerr::Contextf E("%s: open f<%s>", v(wconn), v(foid));
wconn._mu.lock(); wconn._mu.lock();
...@@ -361,6 +363,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -361,6 +363,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
} }
// create in-flight-opening FileH entry and perform open with wconn._mu released // create in-flight-opening FileH entry and perform open with wconn._mu released
// NOTE wconn._atMu is still held because open relies on wconn.at being stable.
f = adoptref(new _FileH()); f = adoptref(new _FileH());
f->wconn = newref(&wconn); f->wconn = newref(&wconn);
f->foid = foid; f->foid = foid;
...@@ -388,6 +391,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -388,6 +391,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
} }
// _open performs actual open of FileH marked as "in-flight-open" in wconn.filehTab. // _open performs actual open of FileH marked as "in-flight-open" in wconn.filehTab.
//
// Called with:
// - wconn.atMu held
// - wconn.mu not locked
// - f.mu not locked
error _FileH::_open() { error _FileH::_open() {
_FileH* f = this; _FileH* f = this;
Conn wconn = f->wconn; Conn wconn = f->wconn;
...@@ -415,7 +423,7 @@ error _FileH::_open() { ...@@ -415,7 +423,7 @@ error _FileH::_open() {
v(f->_headf->name()), f->_headfsize, f->blksize); v(f->_headf->name()), f->_headfsize, f->blksize);
// start watching f // start watching f
// NOTE we are _not_ holding wconn.mu nor f.mu XXX wconn.atMu? // NOTE we are _not_ holding wconn.mu nor f.mu - only wconn.atMu to rely on wconn.at being stable.
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)
......
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