Make file rcu_freed

上级 f9f7aaef
......@@ -8,7 +8,7 @@
u64 namehash(const strbuf<DIRSIZ>&);
struct file : public referenced {
struct file : public referenced, public rcu_freed {
static file* alloc();
file* dup();
int stat(struct stat*);
......@@ -26,6 +26,8 @@ struct file : public referenced {
struct inode *ip;
u32 off;
virtual void do_gc(void);
private:
file();
file& operator=(const file&);
......
......@@ -16,7 +16,8 @@ file::alloc(void)
}
file::file(void)
: type(file::FD_NONE), readable(0), writable(0),
: rcu_freed("file"),
type(file::FD_NONE), readable(0), writable(0),
socket(0), pipe(nullptr), ip(nullptr), off(0)
{
}
......@@ -32,6 +33,12 @@ file::onzero(void) const
netclose(socket);
else if(type != file::FD_NONE)
panic("file::close bad type");
gc_delayed((file*)this);
}
void
file::do_gc(void)
{
delete this;
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论