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

transports/tcp/: Call take_error on TCP socket #2458

Merged
merged 5 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@

# `libp2p` facade crate

## Version 0.42.1 [unreleased]

- Update individual crates.
- `libp2p-tcp`

## Version 0.42.0 [2022-01-27]

- Update individual crates.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = "1.56.1"
description = "Peer-to-peer networking library"
version = "0.42.0"
version = "0.42.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down Expand Up @@ -106,7 +106,7 @@ smallvec = "1.6.1"
libp2p-deflate = { version = "0.31.0", path = "transports/deflate", optional = true }
libp2p-dns = { version = "0.31.0", path = "transports/dns", optional = true, default-features = false }
libp2p-mdns = { version = "0.34.0", path = "protocols/mdns", optional = true }
libp2p-tcp = { version = "0.31.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-tcp = { version = "0.31.1", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.33.0", path = "transports/websocket", optional = true }

[dev-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions transports/tcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.31.1 [unreleased]

- Call `TcpSocket::take_error` to report connection establishment erorrs early.
mxinden marked this conversation as resolved.
Show resolved Hide resolved

# 0.31.0 [2022-01-27]

- Update dependencies.
Expand Down
2 changes: 1 addition & 1 deletion transports/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-tcp"
edition = "2021"
rust-version = "1.56.1"
description = "TCP/IP transport protocol for libp2p"
version = "0.31.0"
version = "0.31.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
2 changes: 2 additions & 0 deletions transports/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ mod tests {
panic!("No TCP port in address: {}", a)
}
ready_tx.send(a).await.ok();
}
ListenerEvent::Upgrade { .. } => {
return;
}
_ => {}
Expand Down
11 changes: 10 additions & 1 deletion transports/tcp/src/provider/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@ impl Provider for Tcp {

fn new_stream(s: net::TcpStream) -> BoxFuture<'static, io::Result<Self::Stream>> {
async move {
// Taken from [`Async::connect`].

let stream = Async::new(s)?;

// The stream becomes writable when connected.
stream.writable().await?;
Ok(stream)

// Check if there was an error while connecting.
match stream.get_ref().take_error()? {
None => Ok(stream),
Some(err) => Err(err),
}
}
.boxed()
}
Expand Down