mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Check file_table before use
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
00e6905d93
commit
2f097ab8f8
@ -27,12 +27,13 @@ impl FdDirOps {
|
||||
.parent(parent)
|
||||
.build()
|
||||
.unwrap();
|
||||
file_table
|
||||
.lock()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.read()
|
||||
.register_observer(Arc::downgrade(&fd_inode) as _);
|
||||
// Guard against the race condition when procfs is being accessed for an exiting process,
|
||||
// whose file table may have already been released.
|
||||
if let Some(file_table_ref) = file_table.lock().as_ref() {
|
||||
file_table_ref
|
||||
.read()
|
||||
.register_observer(Arc::downgrade(&fd_inode) as _);
|
||||
}
|
||||
|
||||
fd_inode
|
||||
}
|
||||
|
Reference in New Issue
Block a user