mikros: Do not close stdio after every use

This commit is contained in:
pjht 2024-09-22 14:53:19 -05:00
parent 7bd76e861a
commit 5ccb37a3f7
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -26,8 +26,9 @@ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
return Ok(0);
};
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
let num_bytes = file.read(buf)?;
Ok(num_bytes)
let res = file.read(buf);
crate::mem::drop(file); // do not close the temporary file struct
res
}
}
@ -49,7 +50,9 @@ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
return Ok(0);
};
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
file.write(buf)
let res = file.write(buf);
crate::mem::drop(file); // do not close the temporary file struct
res
}
fn flush(&mut self) -> io::Result<()> {
@ -75,7 +78,9 @@ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
return Ok(0);
};
let file = File { fs_pid: fd.0, fd: fd.1, pos: AtomicUsize::new(0) };
file.write(buf)
let res = file.write(buf);
crate::mem::drop(file); // do not close the temporary file struct
res
}
fn flush(&mut self) -> io::Result<()> {