Commit 7b36fe41 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9f829258
......@@ -967,18 +967,19 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
_FileH& f = *this;
// NOTE virtmem lock is held by virtmem caller
// XXX locking ok?
f.wconn->_atMu.RLock(); // e.g. f._headfsize
f._mmapMu.lock(); // f._pinned, f._mmaps
f.wconn->_atMu.RLock(); // e.g. f._headfsize
f.wconn->_filehMu.RLock(); // f._state FIXME too coarse
f._mmapMu.lock(); // f._pinned, f._mmaps
defer([&]() {
f._mmapMu.unlock();
f.wconn->_filehMu.RUnlock();
f.wconn->_atMu.RUnlock();
});
xerr::Contextf E("%s: %s: mmap [#%ld +%ld)", v(f.wconn), v(f), blk_start, blk_len);
etrace("");
if (f._state >= _FileHClosing) // XXX locking
if (f._state >= _FileHClosing)
return make_pair(nil, E(os::ErrClosed));
error err;
......
......@@ -221,6 +221,7 @@ private:
//
// It is safe to use FileH from multiple threads simultaneously.
enum _FileHState {
// NOTE order of states is semantically important
_FileHOpening = 0, // FileH open is in progress
_FileHOpened = 1, // FileH is opened and can be used
_FileHClosing = 2, // FileH close is in progress
......
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