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

ignore dropped connections #502

Merged
merged 2 commits into from
Oct 16, 2019
Merged

Conversation

seunlanlege
Copy link
Contributor

@seunlanlege seunlanlege commented Oct 15, 2019

Previously If there's no peer_addr on the socket, this causes the tcp-server to panic.

let listener = tokio::net::TcpListener::bind(&address)?;
let connections = SuspendableStream::new(listener.incoming());
let server = connections.map(move |socket| {
let peer_addr = socket.peer_addr().expect("Unable to determine socket peer address");
trace!(target: "tcp", "Accepted incoming connection from {}", &peer_addr);
let (sender, receiver) = mpsc::channel(65536);

Instead of panicking this PR instead ignores the connection as it has most likely been dropped by the client.

closes #500

@dvdplm
Copy link
Contributor

dvdplm commented Oct 15, 2019

PR description please?

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm but a test would be nice.

let peer_addr = match socket.peer_addr() {
Ok(addr) => addr,
Err(e) => {
trace!(target: "tcp", "Unable to determine socket peer address, ignoring connection {}", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
trace!(target: "tcp", "Unable to determine socket peer address, ignoring connection {}", e);
warn!(target: "tcp", "Unable to determine socket peer address, ignoring connection {}", e);

@niklasad1
Copy link
Member

@seunlanlege after this gets merged please update the version number and release a new version on crates.io so we can use it in parity-ethereum

Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm, just address David's grumble.

@niklasad1 niklasad1 merged commit d3d8c6b into master Oct 16, 2019
@niklasad1 niklasad1 deleted the seun-ignore-dropped-connections branch October 16, 2019 08:00
@niklasad1 niklasad1 mentioned this pull request Oct 18, 2019
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.

Ignore connections that have no peer_addr
4 participants