From 12dbda986ee89726d62edc609f7928307ce5390c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 3 Aug 2023 06:54:50 +0100 Subject: [PATCH] test: fix test_h2_connection_drop spurious hang fixes #3061 --- awc/src/client/connection.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/awc/src/client/connection.rs b/awc/src/client/connection.rs index 64075eae8..12d00914a 100644 --- a/awc/src/client/connection.rs +++ b/awc/src/client/connection.rs @@ -394,6 +394,8 @@ mod test { #[actix_rt::test] async fn test_h2_connection_drop() { + env_logger::try_init().ok(); + let addr = "127.0.0.1:0".parse::().unwrap(); let listener = net::TcpListener::bind(addr).unwrap(); let local = listener.local_addr().unwrap(); @@ -428,11 +430,18 @@ mod test { if this.start_from.elapsed() > Duration::from_secs(10) { panic!("connection should be gone and can not be ready"); } else { - let _ = this.interval.poll_tick(cx); - Poll::Pending + match this.interval.poll_tick(cx) { + Poll::Ready(_) => { + // prevents spurious test hang + this.interval.reset(); + + Poll::Pending + } + Poll::Pending => Poll::Pending, + } } } - Err(_) => Poll::Ready(()), + Err(err) => Poll::Ready(()), } } }