fix(s2n-quic): make AsyncWrite::poll_flush a no-op #2347
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
The current implementation of
tokio::io::AsyncWrite::poll_flush
performs a full flush of buffers, which means it waits for the peer to acknowledge all of the outstanding in the stream. However, this isn't the behavior most trait usage expects. Instead, it expectspoll_flush
to flush any temporary buffers to the socket. You can see this expectation in theimpl AsyncWrite for TcpStream
:https://github.com/tokio-rs/tokio/blob/679d7657dc267a4d6472597c91cdda8792cf9e97/tokio/src/net/tcp/stream.rs#L1358-L1359
An example of our current behavior going wrong is the tokio
framed
utilities:https://github.com/tokio-rs/tokio/blob/679d7657dc267a4d6472597c91cdda8792cf9e97/tokio-util/src/codec/framed_impl.rs#L263
In this case, random calls to
poll_write
will result in a full flush of the stream, rather than pipelining the buffer. When comparing s2n-quic streams to something like TCP, we will be much worse.For the solution, I have made all of our
poll_flush
trait impls as no-ops to match TCP behavior. We preserve the associatedpoll_flush
that keeps the original behavior, in case applications are wanting to do that.Call-outs:
This is technically a behavior change. It's possible that an application is depending on this behavior to track when the stream was completely ACKed by the peer. But in reality, it's more likely that the application is expecting our trait impls to match what TCP does, which makes no guarantees. So I think the behavior change is preferred.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.