2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-02-06 04:35:32 +00:00

Merge pull request #846 from ryanbrainard/book-fix-accept-loop

Book: Accept Loop Variable Fixes
This commit is contained in:
Yoshua Wuyts 2020-08-03 13:38:20 +02:00 committed by GitHub
commit 19dcced77b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,10 +121,10 @@ async fn accept_loop(addr: impl ToSocketAddrs) -> Result<()> {
let listener = TcpListener::bind(addr).await?;
let mut incoming = listener.incoming();
while let Some(result) = incoming.next().await {
let stream = match stream {
let stream = match result {
Err(ref e) if is_connection_error(e) => continue, // 1
Err(e) => {
eprintln!("Error: {}. Pausing for 500ms."); // 3
eprintln!("Error: {}. Pausing for 500ms.", e); // 3
task::sleep(Duration::from_millis(500)).await; // 2
continue;
}