Commit 744dc883 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c3e1d21f
...@@ -329,9 +329,11 @@ error _Conn::close() { ...@@ -329,9 +329,11 @@ error _Conn::close() {
// - virt_lock // - virt_lock
// - wconn.atMu.R // - wconn.atMu.R
// - wconn.filehMu unlocked // - wconn.filehMu unlocked
err = f->_closeLocked(); if (!closing) {
err = f->_closeLocked(/*force=*/true);
if (err != nil) if (err != nil)
reterr1(err); reterr1(err);
}
// wait for f close to complete, as it might be that f.close was called // wait for f close to complete, as it might be that f.close was called
// simultaneously to us or just before. f is removed from // simultaneously to us or just before. f is removed from
...@@ -868,7 +870,7 @@ error _FileH::close() { ...@@ -868,7 +870,7 @@ error _FileH::close() {
wconn->_atMu.RUnlock(); wconn->_atMu.RUnlock();
}); });
return fileh._closeLocked(); return fileh._closeLocked(/*force=*/false);
} }
// _closeLocked serves FileH.close and Conn.close. // _closeLocked serves FileH.close and Conn.close.
...@@ -876,7 +878,7 @@ error _FileH::close() { ...@@ -876,7 +878,7 @@ error _FileH::close() {
// Must be called with the following locks held by caller: // Must be called with the following locks held by caller:
// - virt_lock // - virt_lock
// - wconn.atMu // - wconn.atMu
error _FileH::_closeLocked() { error _FileH::_closeLocked(bool force) {
_FileH& fileh = *this; _FileH& fileh = *this;
Conn wconn = fileh.wconn; Conn wconn = fileh.wconn;
...@@ -893,7 +895,7 @@ error _FileH::_closeLocked() { ...@@ -893,7 +895,7 @@ error _FileH::_closeLocked() {
if (fileh._nopen <= 0) if (fileh._nopen <= 0)
panic("BUG: fileh.close: fileh._nopen <= 0"); panic("BUG: fileh.close: fileh._nopen <= 0");
fileh._nopen--; fileh._nopen--;
if (fileh._nopen > 0) if (fileh._nopen > 0 && !force)
return nil; return nil;
// last open went away - real close. // last open went away - real close.
......
...@@ -264,7 +264,7 @@ public: ...@@ -264,7 +264,7 @@ public:
string String() const; string String() const;
error _open(); error _open();
error _closeLocked(); error _closeLocked(bool force);
}; };
// Mapping represents one memory mapping of FileH. // Mapping represents one memory mapping of FileH.
......
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