Commit 35fec6c6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c6da1a38
...@@ -114,6 +114,8 @@ struct Conn { ...@@ -114,6 +114,8 @@ struct Conn {
sync::Mutex _filemu; sync::Mutex _filemu;
dict<Oid, _File*> _filetab; // {} foid -> _file dict<Oid, _File*> _filetab; // {} foid -> _file
error close();
private: private:
void _pinner(IContext *ctx); void _pinner(IContext *ctx);
void _pin1(PinReq *req); void _pin1(PinReq *req);
...@@ -257,28 +259,37 @@ tuple<Conn*, error> WCFS::connect(Tid at) { ...@@ -257,28 +259,37 @@ tuple<Conn*, error> WCFS::connect(Tid at) {
// close releases resources associated with wconn. // close releases resources associated with wconn.
// XXX what happens to file mmappings? // XXX what happens to file mmappings?
error Conn::close(wconn) { error Conn::close() { // XXX error -> void?
Conn &wconn = *this; Conn &wconn = *this;
wconn._wlink.close(); wconn._wlink->close(); // XXX err
#if 0
wconn._pinCancel() wconn._pinCancel()
try: try:
wconn._pinWG.wait() wconn._pinWG.wait()
except Exception as e: # canceled - ok except Exception as e: // canceled - ok
if e is not context.canceled: if e is not context.canceled:
raise raise
#endif
// 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
// longer maintain consistent view. // longer maintain consistent view.
with wconn._filemu: wconn._filemu.lock();
for f in wconn._filetab.values(): defer([&]() {
f.headf.close() wconn._filemu.unlock();
f.headf = None });
# XXX stop watching f for (auto _ : wconn._filetab) {
auto f = _.second;
f->headf.close(); // XXX err
//f->headf = None
// XXX stop watching f
}
wconn._filetab = None wconn._filetab.clear();
return nil; // XXX -> err ?
} }
// _pinner receives pin messages from wcfs and adjusts wconn mappings. // _pinner receives pin messages from wcfs and adjusts wconn mappings.
...@@ -498,8 +509,8 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ? ...@@ -498,8 +509,8 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ?
wlink._rxmu.lock(); wlink._rxmu.lock();
wlink._rxdown = true; // don't allow new rxtab registers wlink._rxdown = true; // don't allow new rxtab registers
wlink._rxmu.unlock(); wlink._rxmu.unlock();
for (auto rxqi : wlink._rxtab) { for (auto _ : wlink._rxtab) {
auto rxq = rxqi.second; auto rxq = _.second;
rxq.close(); rxq.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