summaryrefslogtreecommitdiff
path: root/src/sys/aio.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2017-09-03 14:27:57 -0600
committerAlan Somers <asomers@gmail.com>2017-09-03 14:27:57 -0600
commitbd2cda18cec3d2acb1f7bb37778be557029b0268 (patch)
treebbc44568c20a417cc19c37e0de4eddf6894c691c /src/sys/aio.rs
parent0c9437338dbf36bb29d52e37e0c952ea1d55d800 (diff)
downloadnix-bd2cda18cec3d2acb1f7bb37778be557029b0268.zip
Fixed error handling in `AioCb::{fsync,read,write}`
Previously, the `AioCb`'s `in_progress` field would erroneously be set to `true`, even if the syscall had an error Fixes #714
Diffstat (limited to 'src/sys/aio.rs')
-rw-r--r--src/sys/aio.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index 5d56f1cd..22bd3959 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -232,16 +232,22 @@ impl<'a> AioCb<'a> {
/// An asynchronous version of `fsync`.
pub fn fsync(&mut self, mode: AioFsyncMode) -> Result<()> {
let p: *mut libc::aiocb = &mut self.aiocb;
- self.in_progress = true;
- Errno::result(unsafe { libc::aio_fsync(mode as libc::c_int, p) }).map(drop)
+ Errno::result(unsafe {
+ libc::aio_fsync(mode as libc::c_int, p)
+ }).map(|_| {
+ self.in_progress = true;
+ })
}
/// Asynchronously reads from a file descriptor into a buffer
pub fn read(&mut self) -> Result<()> {
assert!(self.mutable, "Can't read into an immutable buffer");
let p: *mut libc::aiocb = &mut self.aiocb;
- self.in_progress = true;
- Errno::result(unsafe { libc::aio_read(p) }).map(drop)
+ Errno::result(unsafe {
+ libc::aio_read(p)
+ }).map(|_| {
+ self.in_progress = true;
+ })
}
/// Retrieve return status of an asynchronous operation. Should only be
@@ -257,8 +263,11 @@ impl<'a> AioCb<'a> {
/// Asynchronously writes from a buffer to a file descriptor
pub fn write(&mut self) -> Result<()> {
let p: *mut libc::aiocb = &mut self.aiocb;
- self.in_progress = true;
- Errno::result(unsafe { libc::aio_write(p) }).map(drop)
+ Errno::result(unsafe {
+ libc::aio_write(p)
+ }).map(|_| {
+ self.in_progress = true;
+ })
}
}