feat: add shutdown timeout
This commit is contained in:
@@ -662,6 +662,7 @@ async fn transfer<I, O>(inbound: I, outbound: O) -> Result<()>
|
|||||||
let (mut ro, mut wo) = tokio::io::split(outbound);
|
let (mut ro, mut wo) = tokio::io::split(outbound);
|
||||||
// IO copy timeout 6 HOURS
|
// IO copy timeout 6 HOURS
|
||||||
let tcp_io_copy_timeout = Duration::from_secs(6 * 3600);
|
let tcp_io_copy_timeout = Duration::from_secs(6 * 3600);
|
||||||
|
let shutdown_tcp_timeout = Duration::from_secs(60);
|
||||||
let client_to_server = async move {
|
let client_to_server = async move {
|
||||||
// let copy_result = time::timeout(tcp_io_copy_timeout, tokio::io::copy(&mut ri, &mut wo));
|
// let copy_result = time::timeout(tcp_io_copy_timeout, tokio::io::copy(&mut ri, &mut wo));
|
||||||
let copy_result = time::timeout(
|
let copy_result = time::timeout(
|
||||||
@@ -669,7 +670,7 @@ async fn transfer<I, O>(inbound: I, outbound: O) -> Result<()>
|
|||||||
copy_data(&mut ri, &mut wo),
|
copy_data(&mut ri, &mut wo),
|
||||||
);
|
);
|
||||||
let r = copy_result.await;
|
let r = copy_result.await;
|
||||||
wo.shutdown().await.ok();
|
time::timeout(shutdown_tcp_timeout, wo.shutdown()).await.ok();
|
||||||
match r {
|
match r {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("TCP copy timeout: {}", e);
|
error!("TCP copy timeout: {}", e);
|
||||||
@@ -685,7 +686,7 @@ async fn transfer<I, O>(inbound: I, outbound: O) -> Result<()>
|
|||||||
copy_data(&mut ro, &mut wi),
|
copy_data(&mut ro, &mut wi),
|
||||||
);
|
);
|
||||||
let r = copy_result.await;
|
let r = copy_result.await;
|
||||||
wi.shutdown().await.ok();
|
time::timeout(shutdown_tcp_timeout, wi.shutdown()).await.ok();
|
||||||
match r {
|
match r {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("TCP copy timeout: {}", e);
|
error!("TCP copy timeout: {}", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user