Skip to content

Commit

Permalink
I/O simulation: always fail after the first failure (#141)
Browse files Browse the repository at this point in the history
It simulates better a disk or network error that the previous behavior of only failing once.
  • Loading branch information
Tpt authored Oct 11, 2022
1 parent 2bbbae4 commit 5afbfcc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ pub fn set_number_of_allowed_io_operations(val: usize) {
macro_rules! try_io {
($e:expr) => {{
if crate::error::IO_COUNTER_BEFORE_ERROR
.fetch_sub(1, ::std::sync::atomic::Ordering::Relaxed) ==
0
.fetch_update(
::std::sync::atomic::Ordering::SeqCst,
::std::sync::atomic::Ordering::SeqCst,
|v| Some(v.saturating_sub(1)),
)
.unwrap() == 0
{
Err(crate::error::Error::Io(::std::io::Error::new(
::std::io::ErrorKind::Other,
Expand Down

0 comments on commit 5afbfcc

Please sign in to comment.