Commit 12315d18 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a634a113
...@@ -610,13 +610,16 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -610,13 +610,16 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
FileH f; bool ok; FileH f; bool ok;
tie(f, ok) = wconn._filehTab.get_(foid); tie(f, ok) = wconn._filehTab.get_(foid);
if (ok) { if (ok) {
f->_nopen++; // XXX lock by f.mu ?
wconn._mu.Unlock(); wconn._mu.Unlock();
f->_openReady.recv(); f->_openReady.recv();
if (f->_openErr != nil) if (f->_openErr != nil) {
// XXX lock/unlock wconn._mu around nopen-- ?
f->_nopen--;
return make_pair(nil, E(f->_openErr)); return make_pair(nil, E(f->_openErr));
}
// XXX incref open count
return make_pair(f, nil); return make_pair(f, nil);
} }
...@@ -630,12 +633,15 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -630,12 +633,15 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
f->_headf = nil; f->_headf = nil;
f->blksize = 0; f->blksize = 0;
f->_headfsize = 0; f->_headfsize = 0;
f->_nopen = 1;
f->_closed = false;
bool retok = false; bool retok = false;
wconn._filehTab[foid] = f; wconn._filehTab[foid] = f;
defer([&]() { defer([&]() {
if (!retok) { if (!retok) {
wconn._mu.Lock(); wconn._mu.Lock();
f->_nopen--; // XXX locking ok?
// XXX assert filehTab[foid] == f // XXX assert filehTab[foid] == f
wconn._filehTab.erase(foid); wconn._filehTab.erase(foid);
wconn._mu.Unlock(); wconn._mu.Unlock();
......
...@@ -181,7 +181,7 @@ struct _Conn : object { ...@@ -181,7 +181,7 @@ struct _Conn : object {
sync::RWMutex _atMu; sync::RWMutex _atMu;
zodb::Tid at; zodb::Tid at;
sync::RWMutex _mu; // _atMu.W | _atMu.R + _mu sync::RWMutex _mu; // _atMu.W | _atMu.R + _mu XXX -> _filehMu ?
error _downErr; // !nil if connection is closed or no longer operational error _downErr; // !nil if connection is closed or no longer operational
dict<zodb::Oid, FileH> _filehTab; // {} foid -> fileh dict<zodb::Oid, FileH> _filehTab; // {} foid -> fileh
...@@ -238,6 +238,8 @@ struct _FileH : object { ...@@ -238,6 +238,8 @@ struct _FileH : object {
sync::Mutex _mu; // atMu.W | atMu.R + _mu sync::Mutex _mu; // atMu.W | atMu.R + _mu
dict<int64_t, zodb::Tid> _pinned; // {} blk -> rev that wcfs already sent us for this file dict<int64_t, zodb::Tid> _pinned; // {} blk -> rev that wcfs already sent us for this file
vector<Mapping> _mmaps; // []Mapping ↑blk_start mappings of this file vector<Mapping> _mmaps; // []Mapping ↑blk_start mappings of this file
// XXX protect by wconn.mu ?
int _nopen; // number of times Conn.open returned this fileh int _nopen; // number of times Conn.open returned this fileh
bool _closed; // y after .close() bool _closed; // y after .close()
......
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