mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
net: accept ConnectionReset in shutdown_after_tcp_reset test (#8196)
The test asserts shutdown() returns Ok(()) after the peer resets the connection (linger = 0). This holds on Linux and macOS, but on FreeBSD the kernel can finish processing the RST before shutdown() runs, so it returns ConnectionReset and the test fails intermittently -- the oneshot only synchronizes the application-level drop, not the kernel's RST processing. Accept Ok(()) or ConnectionReset for the post-reset shutdown, since both are valid for a connection the peer has already reset.
This commit is contained in:
@@ -44,7 +44,16 @@ async fn shutdown_after_tcp_reset() {
|
||||
connected_tx.send(()).unwrap();
|
||||
|
||||
dropped_rx.await.unwrap();
|
||||
assert_ok!(AsyncWriteExt::shutdown(&mut stream).await);
|
||||
|
||||
// After the peer's RST (linger = 0), `shutdown` returns `Ok(())` on most
|
||||
// platforms, but FreeBSD can surface the reset as `ConnectionReset` when
|
||||
// the kernel processed it before `shutdown` ran. Both are valid for an
|
||||
// already-reset connection.
|
||||
match AsyncWriteExt::shutdown(&mut stream).await {
|
||||
Ok(()) => {}
|
||||
Err(e) if e.kind() == io::ErrorKind::ConnectionReset => {}
|
||||
Err(e) => panic!("unexpected error after reset: {e:?}"),
|
||||
}
|
||||
});
|
||||
|
||||
let (stream, _) = assert_ok!(srv.accept().await);
|
||||
|
||||
Reference in New Issue
Block a user