From: Ian Jackson Date: Wed, 4 Aug 2021 10:26:26 +0000 (+0100) Subject: use proper client http timeout X-Git-Tag: hippotat/1.0.0~347 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=0f3f443258fc45d9611daf5e7a882ca115c21205;p=hippotat.git use proper client http timeout Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index a0e70ab..861053b 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -25,6 +25,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } struct ClientContext<'c,C> { ic: &'c InstanceConfig, + effective_http_timeout: Duration, hclient: &'c Arc>, reporter: &'c parking_lot::Mutex>, } @@ -128,7 +129,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( let resp = c.hclient.request(req); let fut = Box::pin(async move { - let r = async { tokio::time::timeout( c.ic.http_timeout, async { + let r = async { tokio::time::timeout( c.effective_http_timeout, async { let resp = resp.await.context("make request")?; let status = resp.status(); let resp = resp.into_body(); @@ -167,6 +168,9 @@ async fn run_client( reporter: &reporter, hclient: &hclient, ic: &ic, + effective_http_timeout: ic.http_timeout.checked_add(ic.http_timeout_grace) + .ok_or_else(|| anyhow!("calculate effective http timeout ({:?} + {:?})", + ic.http_timeout, ic.http_timeout_grace))?, }; let mut ipif = tokio::process::Command::new("sh")