Skip to content

Commit 3c1303b

Browse files
authored
Disable socket2 dependency on wasi target (#1503)
1 parent 6ff08f9 commit 3c1303b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ serde_with = { version = "3.8.1", default-features = false, features = ["macros"
118118
sha1 = "0.10.0"
119119
sha2 = "0.10.2"
120120
snap = { version = "1.0.5", optional = true }
121-
socket2 = "0.5.5"
122121
stringprep = "0.1.2"
123122
strsim = "0.11.1"
124123
take_mut = "0.2.2"
@@ -247,6 +246,9 @@ features = ["serde", "serde_json-1"]
247246
rustdoc-args = ["--cfg", "docsrs"]
248247
all-features = true
249248

249+
[target.'cfg(not(wasi))'.dependencies]
250+
socket2 = "0.5.5"
251+
250252
# Target-specific dependencies for GSSAPI authentication
251253
[target.'cfg(not(windows))'.dependencies]
252254
cross-krb5 = { version = "0.4.2", optional = true, default-features = false }

src/runtime/stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ async fn tcp_try_connect(address: &SocketAddr) -> Result<TcpStream> {
7474
let stream = TcpStream::connect(address).await?;
7575
stream.set_nodelay(true)?;
7676

77-
let socket = socket2::Socket::from(stream.into_std()?);
7877
#[cfg(not(target_os = "wasi"))]
7978
{
79+
let sock_ref = socket2::SockRef::from(&stream);
8080
let conf = socket2::TcpKeepalive::new().with_time(KEEPALIVE_TIME);
81-
socket.set_tcp_keepalive(&conf)?;
81+
sock_ref.set_tcp_keepalive(&conf)?;
8282
}
83-
let std_stream = std::net::TcpStream::from(socket);
84-
Ok(TcpStream::from_std(std_stream)?)
83+
84+
Ok(stream)
8585
}
8686

8787
pub(crate) async fn tcp_connect(resolved: Vec<SocketAddr>) -> Result<TcpStream> {

0 commit comments

Comments
 (0)