From dedd4f4da152a9b8bc6fc8630733cad041e8e495 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sat, 8 Jun 2024 15:22:45 +0200 Subject: [PATCH] First cancel, then start operation In case we can cancel them already. --- tests/util/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 5f1f73e2..1fe54817 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -223,12 +223,13 @@ where F: Fn(&mut O), { for _ in 0..100 { - start_op(operation); match waker.block_on(operation.cancel()) { Ok(()) => return, - Err(ref err) if err.kind() == io::ErrorKind::NotFound => continue, + Err(ref err) if err.kind() == io::ErrorKind::NotFound => {} Err(err) => panic!("unexpected error canceling operation: {err}"), } + + start_op(operation); } panic!("couldn't cancel operation"); } @@ -254,7 +255,6 @@ pub(crate) fn cancel_all( ) { let mut canceled = 0; for _ in 0..100 { - start_op(); let n = waker .block_on(fd.cancel_all()) .expect("failed to cancel all operations"); @@ -262,6 +262,8 @@ pub(crate) fn cancel_all( if canceled >= expected { return; } + + start_op(); } panic!("couldn't cancel all expected operations"); }