Skip to content

Commit

Permalink
eprintln connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Dec 16, 2023
1 parent 167c314 commit f1e7d58
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn serve(args: Args, running: Arc<AtomicBool>) -> Result<Vec<JoinHandle<()>>> {
let (cnx, addr) = listener.accept().await.unwrap();
let Ok(stream) = tls_accepter.accept(cnx).await else {
eprintln!(
"error during tls handshake connection from {}",
"Error during tls handshake connection from {}",
addr
);
continue;
Expand Down Expand Up @@ -161,9 +161,20 @@ where
let hyper_service =
service_fn(move |request: Request<Incoming>| handle.clone().call(request, addr));

let _ = Builder::new(TokioExecutor::new())
let ret = Builder::new(TokioExecutor::new())
.serve_connection_with_upgrades(stream, hyper_service)
.await;

if let Err(err) = ret {
let scope = match addr {
Some(addr) => format!(" from {}", addr),
None => String::new(),
};
match err.downcast_ref::<std::io::Error>() {
Some(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => {}
_ => eprintln!("Error serving connection{}: {}", scope, err),
}
}
}

fn create_listener(addr: SocketAddr) -> Result<TcpListener> {
Expand Down

0 comments on commit f1e7d58

Please sign in to comment.