-
Notifications
You must be signed in to change notification settings - Fork 957
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 tokio TcpStream #2725
Conversation
// writable we check for `take_socket_error` to see if the connect | ||
// actually hit an error or not. | ||
// | ||
// If all that succeeded then we ship everything on up. | ||
stream.writable().await?; |
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.
looking at fn writable
this seems to be doing sth different than what connect_mio
calls under the hood
poll_fn(|cx| stream.io.registration().poll_write_ready(cx)).await?;
vs
pub async fn writable(&self) -> io::Result<()> {
self.ready(Interest::WRITABLE).await?;
Ok(())
}
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.
Correct. I was following the recommendation in the last paragraph of the poll_write_ready
docs:
/// Polls for write readiness.
///
/// If the tcp stream is not currently ready for writing, this method will
/// store a clone of the `Waker` from the provided `Context`. When the tcp
/// stream becomes ready for writing, `Waker::wake` will be called on the
/// waker.
///
/// Note that on multiple calls to `poll_write_ready` or `poll_write`, only
/// the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup. (However, `poll_read_ready` retains a
/// second, independent waker.)
///
/// This function is intended for cases where creating and pinning a future
/// via [`writable`] is not feasible. Where possible, using [`writable`] is
/// preferred, as this supports polling from multiple tasks at once.
Do you see any problems with that @dignifiedquire?
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.
I see, that makes sense, seems like using writable is the right call to make here 👍
Description
See e04e95a for the rational.
With tokio
v1.19.0
released,TcStream
exposestake_error
.This commit applies the same fix from e04e95a to the tokio TCP provider.
Links to any relevant issues
Corresponding merged pull request for the async-std side: #2458
Tokio pull request: tokio-rs/tokio#4739
Open Questions
Change checklist