Bug fix and a note about funny semantics of close with a shared file table

上级 f7766586
......@@ -58,11 +58,16 @@ public:
}
void close(int fd) {
struct file *f = ofile_[fd];
// XXX(sbw) if f->ref_ > 1 the kernel will not actually close
// the file when this function returns (i.e. sys_close can return
// while the file/pipe/socket is still open). Maybe we should clear
// ofile_[fd], wait until f.ref_ == 1, f->dec(), and then return.
acquire(&lock_);
struct file *f = ofile_[fd];
ofile_[fd] = nullptr;
release(&lock_);
if (f)
f->dec();
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论