-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
There was a problem hiding this 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?
src/libstd/net/tcp.rs
Outdated
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(); |
There was a problem hiding this comment.
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?
Oh also, I think tidy is failing |
@bors r=alexcrichton |
📌 Commit 82efdaa has been approved by |
🔒 Merge conflict |
@bors r=alexcrichton |
📌 Commit b9eb88d has been approved by |
⌛ Testing commit b9eb88d8a0a7158e287f262964492d0c95c038ce with merge 00312896f0a9d560627e63e590d6ff7e7e27a454... |
💔 Test failed - status-appveyor |
This breaks the "single syscall rule", but it's really annoying to hand write and is pretty foundational.
@bors r=alexcrichton |
📌 Commit 8c92da3 has been approved by |
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
☀️ Test successful - status-appveyor, status-travis |
Why check the time out for zeros after initiating the connect? Thanks |
We typically do that because zero length durations do not behave as
expected in many APIs. I checked the documentation for poll and select and
it does behave here so we could remove the timeout. A zero length timeout
is kind of useless tin this method though. There's almost no chance the
connection would have finished in time.
…On Sat, Jul 15, 2017 at 11:35 AM setharnold ***@***.***> wrote:
Why check the time out for zeros *after* initiating the connect?
Thanks
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#43062 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABY2UQoMAcZDLYwd-sV01npvSWt8IS-6ks5sOQZmgaJpZM4ON66w>
.
|
This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.
r? @alexcrichton
cc @rust-lang/libs