Skip to content

Commit 3469009

Browse files
committed
Auto merge of #11735 - bebecue:backport-11733, r=weihanglo
[beta-1.68] backport #11733 backport #11733
2 parents ddf05ad + a1d5889 commit 3469009

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/cargo/core/package.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -652,23 +652,6 @@ impl<'cfg> PackageSet<'cfg> {
652652
}
653653
}
654654

655-
// When dynamically linked against libcurl, we want to ignore some failures
656-
// when using old versions that don't support certain features.
657-
macro_rules! try_old_curl {
658-
($e:expr, $msg:expr) => {
659-
let result = $e;
660-
if cfg!(target_os = "macos") {
661-
if let Err(e) = result {
662-
warn!("ignoring libcurl {} error: {}", $msg, e);
663-
}
664-
} else {
665-
result.with_context(|| {
666-
anyhow::format_err!("failed to enable {}, is curl not built right?", $msg)
667-
})?;
668-
}
669-
};
670-
}
671-
672655
impl<'a, 'cfg> Downloads<'a, 'cfg> {
673656
/// Starts to download the package for the `id` specified.
674657
///
@@ -749,7 +732,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
749732
// errors here on OSX, but consider this a fatal error to not activate
750733
// HTTP/2 on all other platforms.
751734
if self.set.multiplexing {
752-
try_old_curl!(handle.http_version(HttpVersion::V2), "HTTP2");
735+
crate::try_old_curl!(handle.http_version(HttpVersion::V2), "HTTP2");
753736
} else {
754737
handle.http_version(HttpVersion::V11)?;
755738
}
@@ -761,7 +744,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
761744
// Once the main one is opened we realized that pipelining is possible
762745
// and multiplexing is possible with static.crates.io. All in all this
763746
// reduces the number of connections down to a more manageable state.
764-
try_old_curl!(handle.pipewait(true), "pipewait");
747+
crate::try_old_curl!(handle.pipewait(true), "pipewait");
765748

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

src/cargo/sources/registry/http_remote.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use anyhow::Context;
1414
use cargo_util::paths;
1515
use curl::easy::{HttpVersion, List};
1616
use curl::multi::{EasyHandle, Multi};
17-
use log::{debug, trace};
17+
use log::{debug, trace, warn};
1818
use std::cell::RefCell;
1919
use std::collections::{HashMap, HashSet};
2020
use std::fs::{self, File};
@@ -553,7 +553,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
553553

554554
// Enable HTTP/2 if possible.
555555
if self.multiplexing {
556-
handle.http_version(HttpVersion::V2)?;
556+
crate::try_old_curl!(handle.http_version(HttpVersion::V2), "HTTP2");
557557
} else {
558558
handle.http_version(HttpVersion::V11)?;
559559
}
@@ -565,7 +565,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
565565
// Once the main one is opened we realized that pipelining is possible
566566
// and multiplexing is possible with static.crates.io. All in all this
567567
// reduces the number of connections done to a more manageable state.
568-
handle.pipewait(true)?;
568+
crate::try_old_curl!(handle.pipewait(true), "pipewait");
569569

570570
let mut headers = List::new();
571571
// Include a header to identify the protocol. This allows the server to

src/cargo/util/network.rs

+18
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ where
110110
}
111111
}
112112

113+
// When dynamically linked against libcurl, we want to ignore some failures
114+
// when using old versions that don't support certain features.
115+
#[macro_export]
116+
macro_rules! try_old_curl {
117+
($e:expr, $msg:expr) => {
118+
let result = $e;
119+
if cfg!(target_os = "macos") {
120+
if let Err(e) = result {
121+
warn!("ignoring libcurl {} error: {}", $msg, e);
122+
}
123+
} else {
124+
result.with_context(|| {
125+
anyhow::format_err!("failed to enable {}, is curl not built right?", $msg)
126+
})?;
127+
}
128+
};
129+
}
130+
113131
#[test]
114132
fn with_retry_repeats_the_call_then_works() {
115133
use crate::core::Shell;

0 commit comments

Comments
 (0)