Skip to content

Commit

Permalink
First cancel, then start operation
Browse files Browse the repository at this point in the history
In case we can cancel them already.
  • Loading branch information
Thomasdezeeuw committed Jun 8, 2024
1 parent 2043d42 commit dedd4f4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -254,14 +255,15 @@ pub(crate) fn cancel_all<D: Descriptor, F: FnMut()>(
) {
let mut canceled = 0;
for _ in 0..100 {
start_op();
let n = waker
.block_on(fd.cancel_all())
.expect("failed to cancel all operations");
canceled += n;
if canceled >= expected {
return;
}

start_op();
}
panic!("couldn't cancel all expected operations");
}
Expand Down

0 comments on commit dedd4f4

Please sign in to comment.