diff options
author | Alan Somers <asomers@gmail.com> | 2017-09-03 14:27:57 -0600 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2017-09-03 14:27:57 -0600 |
commit | bd2cda18cec3d2acb1f7bb37778be557029b0268 (patch) | |
tree | bbc44568c20a417cc19c37e0de4eddf6894c691c /src/sys/aio.rs | |
parent | 0c9437338dbf36bb29d52e37e0c952ea1d55d800 (diff) | |
download | nix-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.rs | 21 |
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; + }) } } |