add some timeouts

This commit is contained in:
Jun Kurihara 2022-07-12 01:12:47 +09:00
commit 9c93b1cc31
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 23 additions and 7 deletions

View file

@ -17,8 +17,10 @@ where
return;
}
let fut = self.clone().handle_connection_h3(conn);
let timeout_sec = self.globals.timeout;
self.globals.runtime_handle.spawn(async move {
if let Err(e) = fut.await {
if let Err(e) = tokio::time::timeout(timeout_sec + Duration::from_secs(1), fut).await {
// TODO: ここのtimeoutはどの値を使うべき
warn!("QUIC or HTTP/3 connection failed: {}", e)
}
clients_count.decrement();
@ -79,7 +81,12 @@ where
let self_inner = self.clone();
self.globals.runtime_handle.spawn(async move {
if let Err(e) = self_inner.handle_stream_h3(req, stream, client_addr).await {
if let Err(e) = tokio::time::timeout(
self_inner.globals.timeout + Duration::from_secs(1), // timeout per stream
self_inner.handle_stream_h3(req, stream, client_addr),
)
.await
{
error!("HTTP/3 request failed: {}", e);
}
// // TODO: Work around for timeout