From 70476973b6bc1167d11292092007ceab90ceaf29 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 6 Jul 2022 02:11:15 -0700 Subject: [PATCH] Ignore "unexpected EOF" errors --- src/server.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index f57caf5..65a2e9f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -4,7 +4,7 @@ use std::iter::FusedIterator; use std::net::SocketAddr; use std::sync::atomic::{AtomicI64, Ordering}; use std::sync::{Arc, Mutex}; -use std::thread; +use std::{thread, io}; use std::time::{Duration, Instant}; use anyhow::{bail, ensure, Context}; @@ -451,13 +451,16 @@ async fn do_accept_loop(server: SharedServer) { Ok((stream, remote_addr)) => { let server = server.clone(); tokio::spawn(async move { - // Setting TCP_NODELAY to true appears to trade some throughput for improved - // latency. Testing is required to determine if this is worth keeping. if let Err(e) = stream.set_nodelay(true) { - log::error!("failed to set TCP nodelay: {e}"); + log::error!("failed to set TCP_NODELAY: {e}"); } if let Err(e) = handle_connection(server, stream, remote_addr).await { + if let Some(e) = e.downcast_ref::() { + if e.kind() == io::ErrorKind::UnexpectedEof { + return; + } + } log::debug!("connection to {remote_addr} ended: {e:#}"); } drop(permit);