summaryrefslogtreecommitdiff
path: root/src/sys/aio.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2017-09-03 14:27:20 -0600
committerAlan Somers <asomers@gmail.com>2017-09-03 14:27:20 -0600
commit0c9437338dbf36bb29d52e37e0c952ea1d55d800 (patch)
tree8f1cb1ecb599f01aca44bcc7f98f02e5632349af /src/sys/aio.rs
parent219fcd7adaa7cecd178347782103c9b9cec86c58 (diff)
downloadnix-0c9437338dbf36bb29d52e37e0c952ea1d55d800.zip
AioCb::Drop will now panic for in-progress AioCb
Printing a warning message to stderr isn't really appropriate, because there's no way to guarantee that stderr is even valid. Nor is aio_suspend necessarily an appropriate action to take.
Diffstat (limited to 'src/sys/aio.rs')
-rw-r--r--src/sys/aio.rs22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index abb742f3..5d56f1cd 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -4,8 +4,6 @@ use libc::{c_void, off_t, size_t};
use libc;
use std::fmt;
use std::fmt::Debug;
-use std::io::Write;
-use std::io::stderr;
use std::marker::PhantomData;
use std::mem;
use std::rc::Rc;
@@ -332,24 +330,8 @@ impl<'a> Debug for AioCb<'a> {
impl<'a> Drop for AioCb<'a> {
/// If the `AioCb` has no remaining state in the kernel, just drop it.
- /// Otherwise, collect its error and return values, so as not to leak
- /// resources.
+ /// Otherwise, dropping constitutes a resource leak, which is an error
fn drop(&mut self) {
- if self.in_progress {
- // Well-written programs should never get here. They should always
- // wait for an AioCb to complete before dropping it
- let _ = write!(stderr(), "WARNING: dropped an in-progress AioCb");
- loop {
- let ret = aio_suspend(&[&self], None);
- match ret {
- Ok(()) => break,
- Err(Error::Sys(Errno::EINVAL)) => panic!(
- "Inconsistent AioCb.in_progress value"),
- Err(Error::Sys(Errno::EINTR)) => (), // Retry interrupted syscall
- _ => panic!("Unexpected aio_suspend return value {:?}", ret)
- };
- }
- let _ = self.aio_return();
- }
+ assert!(!self.in_progress, "Dropped an in-progress AioCb");
}
}