Skip to content

Commit 38fd476

Browse files
committed
Fix fetching crates on old versions of libcurl.
1 parent d27b47b commit 38fd476

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/cargo/core/package.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,23 @@ impl<'cfg> PackageSet<'cfg> {
416416
}
417417
}
418418

419+
// When dynamically linked against libcurl, we want to ignore some failures
420+
// when using old versions that don't support certain features.
421+
macro_rules! try_old_curl {
422+
($e:expr, $msg:expr) => {
423+
let result = $e;
424+
if cfg!(target_os = "macos") {
425+
if let Err(e) = result {
426+
warn!("ignoring libcurl {} error: {}", $msg, e);
427+
}
428+
} else {
429+
result.with_context(|_| {
430+
format_err!("failed to enable {}, is curl not built right?", $msg)
431+
})?;
432+
}
433+
};
434+
}
435+
419436
impl<'a, 'cfg> Downloads<'a, 'cfg> {
420437
/// Starts to download the package for the `id` specified.
421438
///
@@ -480,14 +497,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
480497
// errors here on OSX, but consider this a fatal error to not activate
481498
// HTTP/2 on all other platforms.
482499
if self.set.multiplexing {
483-
let result = handle.http_version(HttpVersion::V2);
484-
if cfg!(target_os = "macos") {
485-
if let Err(e) = result {
486-
warn!("ignoring HTTP/2 activation error: {}", e)
487-
}
488-
} else {
489-
result.with_context(|_| "failed to enable HTTP2, is curl not built right?")?;
490-
}
500+
try_old_curl!(handle.http_version(HttpVersion::V2), "HTTP2");
491501
} else {
492502
handle.http_version(HttpVersion::V11)?;
493503
}
@@ -499,7 +509,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
499509
// Once the main one is opened we realized that pipelining is possible
500510
// and multiplexing is possible with static.crates.io. All in all this
501511
// reduces the number of connections done to a more manageable state.
502-
handle.pipewait(true)?;
512+
try_old_curl!(handle.pipewait(true), "pipewait");
503513

504514
handle.write_function(move |buf| {
505515
debug!("{} - {} bytes of data", token, buf.len());

0 commit comments

Comments
 (0)