A lock free filetable::getfile

上级 e5c232e4
...@@ -29,18 +29,13 @@ public: ...@@ -29,18 +29,13 @@ public:
} }
bool getfile(int fd, sref<file> *sf) { bool getfile(int fd, sref<file> *sf) {
file *f;
if (fd < 0 || fd >= NOFILE) if (fd < 0 || fd >= NOFILE)
return false; return false;
acquire(&lock_);
f = ofile_[fd]; scoped_gc_epoch gc;
if (!f) { file* f = ofile_[fd];
release(&lock_); if (!f || !sf->init(f))
return false; return false;
}
sf->init(f);
release(&lock_);
return true; return true;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论