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

net: fix TcpSocket bugs introduced in #4270 #4390

Closed
wants to merge 8 commits into from
Closed

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Jan 11, 2022

This is an attempt to fix bugs of TcpSocket that I accidentally introduced in #4270.

This should pass tokio's test suite, but tokio has very few tests for TcpSocket (this patch adds a few simple assertions), so we need to run hyper's test suite to see if it works correctly.

This patch is still incomplete, and the following twoone hyper's tests are currently failing.

UPD: Timeout in hyper/benches/connect.rs seems to be unrelated to #4270 as it can be reproduced in tokio v1.15.0.
UPD2: Double panic in hyper/tests/integration.rs is due to #4377

I have very little bandwidth on the weekdays, so if anyone knows how to fix these issues, feel free to copy this patch and open a new PR.

@taiki-e taiki-e added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Jan 11, 2022
@taiki-e
Copy link
Member Author

taiki-e commented Jan 11, 2022

Oh, timeout in hyper/benches/connect.rs doesn't seem to happen on linux?: https://github.com/tokio-rs/tokio/runs/4775733526?check_suite_focus=true

EDIT: It seems to be unrelated to #4270 as it can be reproduced in tokio v1.15.0 on macos.

@@ -125,6 +125,7 @@ impl TcpSocket {
socket2::Type::STREAM,
Some(socket2::Protocol::TCP),
)?;
inner.set_nonblocking(true)?;
Copy link
Member

Choose a reason for hiding this comment

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

There should be a way to do this as part of the Socket::new initialization. If there isn't, we need to fix that.

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking we should revert the changes that got us here until this is fixed (unless there is a quick fix).

Copy link
Contributor

Choose a reason for hiding this comment

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

Socket2 supports Type::nonblocking for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed in 08240cc.

@@ -125,6 +125,7 @@ impl TcpSocket {
socket2::Type::STREAM,
Some(socket2::Protocol::TCP),
)?;
inner.set_nonblocking(true)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Socket2 supports Type::nonblocking for this.

match self.inner.connect(&addr.into()) {
// https://github.com/tokio-rs/mio/blob/d400ddfc97212b4a2844d741b095dab2c6d15543/src/sys/unix/tcp.rs#L31
#[cfg(unix)]
Err(e) if e.raw_os_error() != Some(libc::EINPROGRESS) => return Err(e),
Copy link
Contributor

Choose a reason for hiding this comment

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

@carllerche @seanmonstar I think this should fix the issue.

Copy link
Contributor

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

Change to Socket::new and connect LGTM, didn't check the tests.

@taiki-e
Copy link
Member Author

taiki-e commented Jan 11, 2022

The double panic from hyper's test suite also seems to be unrelated to this problem.

I can confirm the double panic on #4391.

@taiki-e taiki-e changed the title [WIP] net: fix TcpSocket bugs introduced in #4270 net: fix TcpSocket bugs introduced in #4270 Jan 11, 2022
@taiki-e taiki-e marked this pull request as ready for review January 11, 2022 18:31
This reverts commit cc8ad36.

That commit caused double panic in hyper's test suite.
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Jan 11, 2022
@taiki-e
Copy link
Member Author

taiki-e commented Jan 11, 2022

Ok, reverting cc8ad36 solves the remaining problems.

@Noah-Kennedy
Copy link
Contributor

Noah-Kennedy commented Jan 11, 2022

I can try debugging this tonight. I have access to MacOS and Windows machines for development.

@taiki-e taiki-e mentioned this pull request Jan 11, 2022

test-hyper:
name: Test hyper
runs-on: ubuntu-latest
Copy link
Member

Choose a reason for hiding this comment

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

Could we run hyper tests on other platforms as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

#4393 (CI part of this PR) contains changes for that.

@carllerche
Copy link
Member

I'm going to close this PR since the changes being fixed were reverted and the CI improvements were merged separately. We need to figure out how we want to move forward w/ mio 0.8 still.

@carllerche carllerche closed this Jan 11, 2022
@Darksonn Darksonn deleted the taiki-e/tcp-socket branch January 12, 2022 08:25
@Thomasdezeeuw
Copy link
Contributor

I'm going to close this PR since the changes being fixed were reverted and the CI improvements were merged separately. We need to figure out how we want to move forward w/ mio 0.8 still.

This is a rather surprising reaction, especially considering the bug wasn't even in Mio. Really the only problem was the missing check for EINPROGRESS which this pr would fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-net Module: tokio/net R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants