Always use close message when available.

This commit is contained in:
4lDO2
2025-02-21 16:50:16 +01:00
parent 7295777985
commit ef0758b9cc
5 changed files with 8 additions and 24 deletions
+4 -8
View File
@@ -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(())
}
+1 -4
View File
@@ -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
View File
@@ -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
View File
@@ -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> {
+1 -4
View File
@@ -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);