revert some intermediate changes to failpoint_sleep_millis_async

This commit is contained in:
Christian Schwarz
2023-05-03 19:42:11 +02:00
parent 08558b83ed
commit dd73c1d793

View File

@@ -61,20 +61,16 @@ pub mod tracing_span_assert;
/// use with fail::cfg("$name", "return(2000)")
#[macro_export]
macro_rules! failpoint_sleep_millis_async {
($name:literal) => {
$crate::failpoint_sleep_millis_async!($name, async {})
};
($name:literal, $pre_sleep:expr) => {{
($name:literal) => {{
let should_sleep: Option<std::time::Duration> = (|| {
fail::fail_point!($name, |v: Option<_>| {
let millis = v.unwrap().parse::<u64>().unwrap();
Some(::std::time::Duration::from_millis(millis))
Some(Duration::from_millis(millis))
});
None
})();
if let Some(d) = should_sleep {
tracing::info!("failpoint {:?}: sleeping for {:?}", $name, d);
$pre_sleep.await;
tokio::time::sleep(d).await;
tracing::info!("failpoint {:?}: sleep done", $name);
}