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

Implement TcpStream::connect_timeout #43062

Merged
merged 1 commit into from
Jul 7, 2017
Merged

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Jul 5, 2017

This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.

r? @alexcrichton

cc @rust-lang/libs

@sfackler sfackler added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 5, 2017
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Implementation looks good to me! I'm not too worried about a single-syscall rule here, TcpStream::connect already violates that anyway. This seems fine to me to land as unstable as well, want to open a tracking issue for this?

Also, can you add a test for a zero-duration being an error, as well as a sub-millisecond duration basically not panicking?

fn connect_timeout_valid() {
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Could you increase this to ~2s just to be super extra sure?

@alexcrichton
Copy link
Member

Oh also, I think tidy is failing

@aidanhs aidanhs added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 5, 2017
@sfackler
Copy link
Member Author

sfackler commented Jul 6, 2017

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Jul 6, 2017

📌 Commit 82efdaa has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jul 6, 2017

🔒 Merge conflict

@sfackler
Copy link
Member Author

sfackler commented Jul 6, 2017

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Jul 6, 2017

📌 Commit b9eb88d has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jul 6, 2017

⌛ Testing commit b9eb88d8a0a7158e287f262964492d0c95c038ce with merge 00312896f0a9d560627e63e590d6ff7e7e27a454...

@bors
Copy link
Contributor

bors commented Jul 6, 2017

💔 Test failed - status-appveyor

This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.
@sfackler
Copy link
Member Author

sfackler commented Jul 7, 2017

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Jul 7, 2017

📌 Commit 8c92da3 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jul 7, 2017

⌛ Testing commit 8c92da3 with merge 54e3fe7...

bors added a commit that referenced this pull request Jul 7, 2017
Implement TcpStream::connect_timeout

This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.

r? @alexcrichton

cc @rust-lang/libs
@bors
Copy link
Contributor

bors commented Jul 7, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 54e3fe7 to master...

@bors bors merged commit 8c92da3 into rust-lang:master Jul 7, 2017
@setharnold
Copy link

Why check the time out for zeros after initiating the connect?

Thanks

@sfackler
Copy link
Member Author

sfackler commented Jul 15, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants