|
|
|
@ -1,8 +1,9 @@ |
|
|
|
|
use crate::error::unexpected::{self, Intoable, Mappable}; |
|
|
|
|
use crate::error::unexpected::{self, Mappable}; |
|
|
|
|
use crate::service; |
|
|
|
|
|
|
|
|
|
use std::{net, pin, sync}; |
|
|
|
|
|
|
|
|
|
use core::time::Duration; |
|
|
|
|
use tokio_util::sync::CancellationToken; |
|
|
|
|
|
|
|
|
|
async fn serve_conn<Conn>( |
|
|
|
@ -21,7 +22,6 @@ async fn serve_conn<Conn>( |
|
|
|
|
req_is_https, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
use core::time::Duration; |
|
|
|
|
use hyper_util::{ |
|
|
|
|
rt::tokio::{TokioExecutor, TokioIo, TokioTimer}, |
|
|
|
|
server::conn::auto::Builder, |
|
|
|
@ -95,8 +95,10 @@ pub async fn listen_http( |
|
|
|
|
worker.done() |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
Err(err) => |
|
|
|
|
return Err(err.into_unexpected_while(format!("accepting new HTTP requests on {addr}"))), |
|
|
|
|
Err(err) => { |
|
|
|
|
log::error!("Failed to accept new HTTP request on {addr}: {err}"); |
|
|
|
|
tokio::time::sleep(Duration::from_secs(2)).await; |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
_ = canceller.cancelled() => { |
|
|
|
@ -144,7 +146,7 @@ pub async fn listen_https( |
|
|
|
|
let stream = match server_config.accept(raw_stream).await { |
|
|
|
|
Ok(s) => s, |
|
|
|
|
Err(err) => { |
|
|
|
|
log::warn!("failed to accept TLS connection on {addr}: {err}"); |
|
|
|
|
log::warn!("Failed to accept TLS connection on {addr}: {err}"); |
|
|
|
|
worker.done(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -154,8 +156,10 @@ pub async fn listen_https( |
|
|
|
|
worker.done(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
Err(err) => |
|
|
|
|
return Err(err.into_unexpected_while(format!("accepting new HTTPS requests on {addr}"))), |
|
|
|
|
Err(err) => { |
|
|
|
|
log::error!("Failed to accept new HTTPS request on {addr}: {err}"); |
|
|
|
|
tokio::time::sleep(Duration::from_secs(2)).await; |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
_ = canceller.cancelled() => { |
|
|
|
|