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

Provide http-config option for curl low-speed-limit/time #5957

Merged
merged 2 commits into from
Sep 3, 2018

Conversation

lostiniceland
Copy link
Contributor

@lostiniceland lostiniceland commented Sep 1, 2018

Fixes #5717

Provides new override options for curl in Cargo http config-section.

[http]
timeout = 2
low-speed-limit = 5

Test with the following during crate-download
sudo tc qdisc add dev eth0 handle 1: root htb default 11 && sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 8bps && sudo tc class add dev eth0 parent 1:1 classid 1:11 htb rate 8bps

Clear with
sudo tc qdisc del dev eth0 root

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@lostiniceland lostiniceland force-pushed the 5717-curl-low_speed branch 2 times, most recently from 28fb126 to 7ed4db1 Compare September 1, 2018 18:39
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could documentation for this option also be added to src/doc?

if let Some(s) = config.get::<Option<u32>>("http.low-speed-limit")? {
return Ok(Some(s));
}
Ok(Some(10))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this always returns Some, perhaps this could return CargoResult<u32> and use .unwrap_or(10) internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the Option, but instead of unwrap_or I've set the default in the function. This way, everything is in one place.

handle.low_speed_limit(config_low_speed_limit)?;
}
if let Some(config_low_speed_time) = low_speed_time(config)? {
handle.low_speed_time(config_low_speed_time)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this conflicts with http_timeout below, but could it suffice to avoid configuring this manually and letting http_timeout below configure it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I just didn't notice the option was configured with the http-timeout.

Fixes rust-lang#5717

low-speed-time was removed because the corresponding curl-option is already set via http.timeout.

removed unnecessary Option.
@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Collaborator

bors commented Sep 3, 2018

📌 Commit d6cde29 has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Sep 3, 2018

⌛ Testing commit d6cde29 with merge 19c865c341814e4eba60c834d35ca6ec5fa45001...

@bors
Copy link
Collaborator

bors commented Sep 3, 2018

💥 Test timed out

@ehuss
Copy link
Contributor

ehuss commented Sep 3, 2018

@bors retry

@bors
Copy link
Collaborator

bors commented Sep 3, 2018

⌛ Testing commit d6cde29 with merge 86c9c51...

bors added a commit that referenced this pull request Sep 3, 2018
Provide http-config option for curl low-speed-limit/time

Fixes #5717

Provides new override options for curl in Cargo http config-section.

```
[http]
timeout = 2
low-speed-limit = 5
```

Test with the following during crate-download
`sudo tc qdisc add dev eth0 handle 1: root htb default 11 && sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 8bps && sudo tc class add dev eth0 parent 1:1 classid 1:11 htb rate 8bps`

Clear with
`sudo tc qdisc del dev eth0 root`
@bors
Copy link
Collaborator

bors commented Sep 3, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 86c9c51 to master...

@bors bors merged commit d6cde29 into rust-lang:master Sep 3, 2018
@ehuss
Copy link
Contributor

ehuss commented Sep 4, 2018

@lostiniceland @alexcrichton I was taking a closer look at this and I was a little concerned. IIUC, this change makes it so that there is no timeout by default (aside from the 30sec connect timeout). If a download hangs midway, it will never time out. Is that intentional?

(As a side note, the docs for timeout is wrong in several ways, I can send a PR later to clarify it.)

@lostiniceland lostiniceland deleted the 5717-curl-low_speed branch September 4, 2018 06:15
@lostiniceland
Copy link
Contributor Author

@ehuss This change keeps the current behavior unless you specify the low-speed-limit. If you set it to 0, it will disable the check completely (see curl-doc). And yes, in this case the download can hang midway I guess.

@dwijnand
Copy link
Member

dwijnand commented Sep 4, 2018

Maybe it's best mention the default in the docs rather than the disable.

@lostiniceland
Copy link
Contributor Author

It is mentioned in the docs

low-speed-limit = 0 # Lower threshold for bytes/sec (10 = default, 0 = disabled)

@dwijnand
Copy link
Member

dwijnand commented Sep 4, 2018

I mean have it as low-speed-limit = 10.. But maybe I'm just too paranoid of how copy-paste happy people are 😄

@lostiniceland
Copy link
Contributor Author

True. Maybe changing the docs to a non-disabled option is better.
@alexcrichton do I need another issue for this or can I just send in a new PR?

@ehuss
Copy link
Contributor

ehuss commented Sep 4, 2018

@lostiniceland In the new code, if you don't specify a timeout, then low_speed_time is never set. It defaults to 0 (disabled), so by default there is no longer a timeout. Previously it defaulted to 30 seconds.

@dwijnand
Copy link
Member

dwijnand commented Sep 4, 2018

It defaults to 0 (disabled)

Where? I see it defaulting to 10 now.

@lostiniceland
Copy link
Contributor Author

lostiniceland commented Sep 4, 2018

Thanks for the thorough review.

The default low_speed_limit is set regardless of the timeout. So without any timeout a dropping connection should be canceled due to the limit 10bps, except you disable it with 0
https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/registry.rs#L397

It should be exactly as before, just that the default of 10 can be overridden.

EDIT: created #5973 to fix the docs

@ehuss
Copy link
Contributor

ehuss commented Sep 4, 2018

Where? I see it defaulting to 10 now.

The low_speed_limit (the bytes per second) is 10. The low_speed_time defaults to 0. Both values must be set for the low-speed detection to work.

The default low_speed_limit is set regardless of the timeout.

I'm talking about the low_speed_time, not the limit.

@alexcrichton
Copy link
Member

Oh yes sorry @ehuss, that was my mistake missing that! @lostiniceland would you be willing to send a PR to re-add the default call to low_speed_time?

@lostiniceland
Copy link
Contributor Author

lostiniceland commented Sep 4, 2018

I will add this to #5973

@alexcrichton
Copy link
Member

Ok, thanks!

@dwijnand
Copy link
Member

dwijnand commented Sep 4, 2018

Man I'm blind..

@ehuss ehuss added this to the 1.30.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not cancel downloads behind proxy just because it is slow
6 participants