From 3f2e3bbc98e6043722becacbab09d57fed8f56cc Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet Date: Sat, 15 Dec 2018 08:24:10 -0500 Subject: [PATCH] tls listener may have been weird :D --- distributed-fly/src/main.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/distributed-fly/src/main.rs b/distributed-fly/src/main.rs index 048c66a..d3e2de3 100644 --- a/distributed-fly/src/main.rs +++ b/distributed-fly/src/main.rs @@ -165,22 +165,25 @@ fn main() { let tls_stream = tls_listener .incoming() .and_then(|stream| proxy::ProxyTcpStream::peek(stream)) - .map_err(|e| error!("error in stream: {}", e)) + .map_err(|e| error!("error in incoming tls conn: {}", e)) .for_each(move |stream| { let remote_addr = stream.peer_addr().unwrap(); let timer = TLS_HANDSHAKE_TIME_HISTOGRAM.start_timer(); - tls_acceptor - .accept_async(stream) - .map_err(|e| error!("error handshake conn: {}", e)) - .and_then(move |stream| { - timer.observe_duration(); - let h = hyper::server::conn::Http::new(); - h.serve_connection( - stream, - service_fn(move |req| serve_http(true, req, &*SELECTOR, remote_addr)), - ) - .map_err(|e| error!("error serving conn: {}", e)) - }) + tokio::spawn( + tls_acceptor + .accept_async(stream) + .map_err(|e| error!("error handshake conn: {}", e)) + .and_then(move |stream| { + timer.observe_duration(); + let h = hyper::server::conn::Http::new(); + h.serve_connection( + stream, + service_fn(move |req| serve_http(true, req, &*SELECTOR, remote_addr)), + ) + .map_err(|e| error!("error serving conn: {}", e)) + }), + ); + Ok(()) }); let make_svc = make_service_fn(|conn: &proxy::ProxyTcpStream| { @@ -227,7 +230,7 @@ fn main() { tokio::spawn( Server::builder(http_stream) .serve(make_svc) - .map_err(|e| error!("error in hyper server: {}", e)), + .map_err(|e| error!("error in http server: {}", e)), ); info!("HTTP listening on {}", addr); @@ -241,7 +244,7 @@ fn main() { .serve(make_service_fn(|_conn: &TcpStream| { service_fn(move |req| fly::metrics::serve_metrics_http(req)) })) - .map_err(|e| error!("error in hyper prom server: {}", e)), + .map_err(|e| error!("error in http prom server: {}", e)), ); info!("Prometheus listening on {}", addr); }