Always use close message when available.
This commit is contained in:
+4
-8
@@ -70,7 +70,7 @@ pub struct FileDescriptor {
|
||||
impl FileDescription {
|
||||
/// Try closing a file, although at this point the description will be destroyed anyway, if
|
||||
/// doing so fails.
|
||||
pub fn try_close(self, wait_for_res: bool) -> Result<()> {
|
||||
pub fn try_close(self) -> Result<()> {
|
||||
event::unregister_file(self.scheme, self.number);
|
||||
|
||||
let scheme = scheme::schemes()
|
||||
@@ -78,18 +78,14 @@ impl FileDescription {
|
||||
.ok_or(Error::new(EBADF))?
|
||||
.clone();
|
||||
|
||||
if wait_for_res {
|
||||
scheme.close(self.number)
|
||||
} else {
|
||||
scheme.on_close(self.number)
|
||||
}
|
||||
scheme.on_close(self.number)
|
||||
}
|
||||
}
|
||||
|
||||
impl FileDescriptor {
|
||||
pub fn close(self, wait_for_res: bool) -> Result<()> {
|
||||
pub fn close(self) -> Result<()> {
|
||||
if let Ok(file) = Arc::try_unwrap(self.description).map(RwLock::into_inner) {
|
||||
file.try_close(wait_for_res)?;
|
||||
file.try_close()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -71,10 +71,7 @@ impl UnmapResult {
|
||||
.and_then(|scheme| scheme.kfunmap(number, base_offset, self.size, self.flags));
|
||||
|
||||
if let Ok(fd) = Arc::try_unwrap(description) {
|
||||
fd.into_inner().try_close(
|
||||
// wait_for_result
|
||||
false,
|
||||
)?;
|
||||
fd.into_inner().try_close()?;
|
||||
}
|
||||
funmap_result?;
|
||||
|
||||
|
||||
+1
-4
@@ -1102,10 +1102,7 @@ impl UserInner {
|
||||
}
|
||||
|
||||
if let Some(to_close) = to_close {
|
||||
let _ = to_close.try_close(
|
||||
// wait_for_result
|
||||
false,
|
||||
);
|
||||
let _ = to_close.try_close();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+1
-4
@@ -177,10 +177,7 @@ pub fn close(fd: FileHandle) -> Result<()> {
|
||||
context.remove_file(fd).ok_or(Error::new(EBADF))?
|
||||
};
|
||||
|
||||
file.close(
|
||||
// wait_for_result
|
||||
true,
|
||||
)
|
||||
file.close()
|
||||
}
|
||||
|
||||
fn duplicate_file(fd: FileHandle, user_buf: UserSliceRo) -> Result<FileDescriptor> {
|
||||
|
||||
@@ -50,10 +50,7 @@ pub fn exit_this_context() -> ! {
|
||||
// Files must be closed while context is valid so that messages can be passed
|
||||
for file_opt in close_files.into_iter() {
|
||||
if let Some(file) = file_opt {
|
||||
let _ = file.close(
|
||||
// wait_for_result
|
||||
false,
|
||||
);
|
||||
let _ = file.close();
|
||||
}
|
||||
}
|
||||
drop(addrspace_opt);
|
||||
|
||||
Reference in New Issue
Block a user