1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 09:42:57 +01:00

test: fix test_h2_connection_drop spurious hang

fixes #3061
This commit is contained in:
Rob Ede 2023-08-03 06:54:50 +01:00
parent 1c60978a89
commit 12dbda986e
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933

View File

@ -394,6 +394,8 @@ mod test {
#[actix_rt::test] #[actix_rt::test]
async fn test_h2_connection_drop() { async fn test_h2_connection_drop() {
env_logger::try_init().ok();
let addr = "127.0.0.1:0".parse::<net::SocketAddr>().unwrap(); let addr = "127.0.0.1:0".parse::<net::SocketAddr>().unwrap();
let listener = net::TcpListener::bind(addr).unwrap(); let listener = net::TcpListener::bind(addr).unwrap();
let local = listener.local_addr().unwrap(); let local = listener.local_addr().unwrap();
@ -428,11 +430,18 @@ mod test {
if this.start_from.elapsed() > Duration::from_secs(10) { if this.start_from.elapsed() > Duration::from_secs(10) {
panic!("connection should be gone and can not be ready"); panic!("connection should be gone and can not be ready");
} else { } else {
let _ = this.interval.poll_tick(cx); match this.interval.poll_tick(cx) {
Poll::Pending Poll::Ready(_) => {
// prevents spurious test hang
this.interval.reset();
Poll::Pending
}
Poll::Pending => Poll::Pending,
}
} }
} }
Err(_) => Poll::Ready(()), Err(err) => Poll::Ready(()),
} }
} }
} }