Commit b45c5aaf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e8f67851
...@@ -514,7 +514,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -514,7 +514,7 @@ error _Conn::resync(zodb::Tid at) {
// TODO if file has no mappings and was not used during whole prev // TODO if file has no mappings and was not used during whole prev
// cycle - forget and stop watching it // cycle - forget and stop watching it
// XXX not yet ready f ? // XXX not yet ready f
// update f._headfsize and remmap to head/f zero regions that are now covered by head/f // update f._headfsize and remmap to head/f zero regions that are now covered by head/f
struct stat st; struct stat st;
...@@ -618,7 +618,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -618,7 +618,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. // NOTE wconn._atMu.R is still held because FileH._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;
...@@ -688,9 +688,8 @@ error _FileH::_open() { ...@@ -688,9 +688,8 @@ error _FileH::_open() {
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 err; return err;
if (ack != "ok") { if (ack != "ok")
return fmt::errorf("watch: %s", v(ack)); return fmt::errorf("watch: %s", v(ack));
}
retok = true; retok = true;
return nil; return nil;
...@@ -702,10 +701,25 @@ error _FileH::_open() { ...@@ -702,10 +701,25 @@ error _FileH::_open() {
error _FileH::close() { error _FileH::close() {
_FileH& fileh = *this; _FileH& fileh = *this;
Conn wconn = fileh.wconn; Conn wconn = fileh.wconn;
// XXX locking ok?
wconn->_atMu.RLock();
defer([&]() {
wconn->_atMu.RUnlock();
});
xerr::Contextf E("%s: close f<%s>", v(wconn), v(fileh.foid)); xerr::Contextf E("%s: close f<%s>", v(wconn), v(fileh.foid));
// XXX change all fileh.mmaps to cause EFAULT on any access after fileh.close // XXX change all fileh.mmaps to cause EFAULT on any access after fileh.close
// XXX "watch foid -" -> wconn.wlink (stop watching the file)
// stop watching f
string ack;
error err;
tie(ack, err) = wconn->_wlink->sendReq(context::background(), fmt::sprintf("watch %s -", v(foid)));
if (err != nil)
return E(err);
if (ack != "ok")
return E(fmt::errorf("unwatch: %s", v(ack)));
// remove fileh from wconn._filehTab // remove fileh from wconn._filehTab
// fileh.close can be called several times and after first call another // fileh.close can be called several times and after first call another
......
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