Route connect test: the listener never accepts, so the test cannot hang
route_connect_retries_connection_refused_until_listener_is_ready blocked in accept() with no deadline. If the client connected to another listener on the reused port, accept() waited forever and the whole verify job held its slot for 39 minutes. The kernel completes a handshake from a listener's backlog, so the connect succeeds without an accept: the listener now only outlives the connect, waiting on a channel with a 30 s ceiling. A lost port race fails the test instead of hanging it. Builds. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3ed5f262ba
commit
4ac96e959d
1 changed files with 10 additions and 3 deletions
|
|
@ -9327,18 +9327,25 @@ Content-Le".to_vec()), |_| {}),
|
|||
let address = reservation.local_addr()?;
|
||||
drop(reservation);
|
||||
|
||||
// The listener never accepts: the kernel completes a handshake from
|
||||
// its backlog, so the client connects as soon as it is bound. Nothing
|
||||
// here can block on a connection that never arrives; the listener only
|
||||
// has to outlive the connect, and gives up waiting after a bound.
|
||||
let (connected, connect_done) = std::sync::mpsc::channel::<()>();
|
||||
let server = thread::spawn(move || -> std::io::Result<()> {
|
||||
thread::sleep(Duration::from_millis(75));
|
||||
let listener = std::net::TcpListener::bind(address)?;
|
||||
let (_stream, _) = listener.accept()?;
|
||||
let _ = connect_done.recv_timeout(Duration::from_secs(30));
|
||||
drop(listener);
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let stream = connect_route_socket(address)?;
|
||||
drop(stream);
|
||||
let stream = connect_route_socket(address);
|
||||
let _ = connected.send(());
|
||||
server
|
||||
.join()
|
||||
.map_err(|_| anyhow!("route readiness test server panicked"))??;
|
||||
drop(stream?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue