refactor: connection handling timeout
This commit is contained in:
parent
7645830c77
commit
8c0bbf17e2
6 changed files with 34 additions and 33 deletions
|
|
@ -70,12 +70,12 @@ where
|
|||
let self_inner = self.clone();
|
||||
let tls_server_name_inner = tls_server_name.clone();
|
||||
self.globals.runtime_handle.spawn(async move {
|
||||
if let Err(e) = tokio::time::timeout(
|
||||
self_inner.globals.proxy_config.connection_handling_timeout,
|
||||
self_inner.h3_serve_stream(req, stream, client_addr, tls_server_name_inner),
|
||||
)
|
||||
.await
|
||||
{
|
||||
let fut = self_inner.h3_serve_stream(req, stream, client_addr, tls_server_name_inner);
|
||||
if let Some(connection_handling_timeout) = self_inner.globals.proxy_config.connection_handling_timeout {
|
||||
if let Err(e) = tokio::time::timeout(connection_handling_timeout, fut).await {
|
||||
warn!("HTTP/3 error on serve stream: {}", e);
|
||||
};
|
||||
} else if let Err(e) = fut.await {
|
||||
warn!("HTTP/3 error on serve stream: {}", e);
|
||||
}
|
||||
request_count.decrement();
|
||||
|
|
|
|||
|
|
@ -91,24 +91,25 @@ where
|
|||
let handling_timeout = self.globals.proxy_config.connection_handling_timeout;
|
||||
|
||||
self.globals.runtime_handle.clone().spawn(async move {
|
||||
timeout(
|
||||
handling_timeout,
|
||||
server_clone.serve_connection_with_upgrades(
|
||||
stream,
|
||||
service_fn(move |req: Request<Incoming>| {
|
||||
serve_request(
|
||||
req,
|
||||
message_handler_clone.clone(),
|
||||
peer_addr,
|
||||
listening_on,
|
||||
tls_enabled,
|
||||
tls_server_name.clone(),
|
||||
)
|
||||
}),
|
||||
),
|
||||
)
|
||||
.await
|
||||
.ok();
|
||||
let fut = server_clone.serve_connection_with_upgrades(
|
||||
stream,
|
||||
service_fn(move |req: Request<Incoming>| {
|
||||
serve_request(
|
||||
req,
|
||||
message_handler_clone.clone(),
|
||||
peer_addr,
|
||||
listening_on,
|
||||
tls_enabled,
|
||||
tls_server_name.clone(),
|
||||
)
|
||||
}),
|
||||
);
|
||||
|
||||
if let Some(handling_timeout) = handling_timeout {
|
||||
timeout(handling_timeout, fut).await.ok();
|
||||
} else {
|
||||
fut.await.ok();
|
||||
}
|
||||
|
||||
request_count.decrement();
|
||||
debug!("Request processed: current # {}", request_count.current());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue