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

.

parent c3e1d21f
......@@ -329,9 +329,11 @@ error _Conn::close() {
// - virt_lock
// - wconn.atMu.R
// - wconn.filehMu unlocked
err = f->_closeLocked();
if (err != nil)
reterr1(err);
if (!closing) {
err = f->_closeLocked(/*force=*/true);
if (err != nil)
reterr1(err);
}
// 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
......@@ -868,7 +870,7 @@ error _FileH::close() {
wconn->_atMu.RUnlock();
});
return fileh._closeLocked();
return fileh._closeLocked(/*force=*/false);
}
// _closeLocked serves FileH.close and Conn.close.
......@@ -876,7 +878,7 @@ error _FileH::close() {
// Must be called with the following locks held by caller:
// - virt_lock
// - wconn.atMu
error _FileH::_closeLocked() {
error _FileH::_closeLocked(bool force) {
_FileH& fileh = *this;
Conn wconn = fileh.wconn;
......@@ -893,7 +895,7 @@ error _FileH::_closeLocked() {
if (fileh._nopen <= 0)
panic("BUG: fileh.close: fileh._nopen <= 0");
fileh._nopen--;
if (fileh._nopen > 0)
if (fileh._nopen > 0 && !force)
return nil;
// last open went away - real close.
......
......@@ -264,7 +264,7 @@ public:
string String() const;
error _open();
error _closeLocked();
error _closeLocked(bool force);
};
// 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