Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network timeout configuration doesn't always work #8516

Closed
ehuss opened this issue Jul 19, 2020 · 1 comment · Fixed by #10456
Closed

network timeout configuration doesn't always work #8516

ehuss opened this issue Jul 19, 2020 · 1 comment · Fixed by #10456
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug

Comments

@ehuss
Copy link
Contributor

ehuss commented Jul 19, 2020

Problem
Cargo seems to mostly ignore the http.timeout configuration.

The problem is that progress function that handles timeouts is not called when there is no network traffic. According to https://curl.haxx.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html, when using the multi interface the progress won't get called during idleness "unless you call the appropriate libcurl function that performs transfers" whatever that means.

Steps

  1. Start a network transfer (cargo fetch).
  2. Pull the network cord.
  3. Wait. Cargo's timeout will not match the value in http.timeout. Typically it seems to time out after 2.5 minutes on Linux and macOS. Windows was a little more confusing (I couldn't really get a good reading).

Possible Solution(s)
Uncertain if there is some way to force libcurl to call the progress function with the multi interface?

Notes

cargo 1.46.0-nightly (4f74d9b2a 2020-07-08)

@ehuss ehuss added C-bug Category: bug A-networking Area: networking issues, curl, etc. labels Jul 19, 2020
@alexcrichton
Copy link
Member

Can you test to see if this diff fixes the issue for you?

diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs
index 1187def1d..07d50041e 100644
--- a/src/cargo/core/package.rs
+++ b/src/cargo/core/package.rs
@@ -899,11 +899,9 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
                 break Ok(pair);
             }
             assert!(!self.pending.is_empty());
-            let timeout = self
-                .set
-                .multi
-                .get_timeout()?
-                .unwrap_or_else(|| Duration::new(5, 0));
+            let min_timeout = Duration::new(1, 0);
+            let timeout = self.set.multi.get_timeout()?.unwrap_or(min_timeout);
+            let timeout = timeout.min(min_timeout);
             self.set
                 .multi
                 .wait(&mut [], timeout)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants