Commit 269f40a9 authored by Renjie Tang's avatar Renjie Tang Committed by Commit Bot

Use ResetStream() instead of CloseStream() in QUIC transport.

CloseStream() will be deprecated. The reason is that this method is not closing the stream silently.
QUIC specifies that when a stream closes, it needs to send out a RESET_STREAM frame to indicate closure reason.
The default error code in CloseStream() is QUIC_RST_ACKNOWLEDGEMENT, which is very uninformative.
ResetStream(), however, allows applications to specify reasons of closure.

Change-Id: Ie0633422ab3838abcaa7c31c4068db32ae11932a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2292857Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Renjie Tang <renjietang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787833}
parent 9e7979ec
......@@ -148,7 +148,10 @@ class QuicTransport::Stream final {
MayDisposeLater();
}
~Stream() { transport_->transport_->session()->CloseStream(id_); }
~Stream() {
transport_->transport_->session()->ResetStream(
id_, quic::QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
}
private:
using ArmingPolicy = mojo::SimpleWatcher::ArmingPolicy;
......@@ -506,13 +509,15 @@ void QuicTransport::OnIncomingBidirectionalStreamAvailable() {
sizeof(options), MOJO_CREATE_DATA_PIPE_FLAG_NONE, 1, 256 * 1024};
if (mojo::CreateDataPipe(&options, &writable_for_outgoing,
&readable_for_outgoing) != MOJO_RESULT_OK) {
transport_->session()->CloseStream(stream->id());
transport_->session()->ResetStream(
stream->id(), quic::QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
// TODO(yhirano): Error the entire connection.
return;
}
if (mojo::CreateDataPipe(&options, &writable_for_incoming,
&readable_for_incoming) != MOJO_RESULT_OK) {
transport_->session()->CloseStream(stream->id());
transport_->session()->ResetStream(
stream->id(), quic::QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
// TODO(yhirano): Error the entire connection.
return;
}
......@@ -547,7 +552,8 @@ void QuicTransport::OnIncomingUnidirectionalStreamAvailable() {
sizeof(options), MOJO_CREATE_DATA_PIPE_FLAG_NONE, 1, 256 * 1024};
if (mojo::CreateDataPipe(&options, &writable_for_incoming,
&readable_for_incoming) != MOJO_RESULT_OK) {
transport_->session()->CloseStream(stream->id());
transport_->session()->ResetStream(
stream->id(), quic::QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
// TODO(yhirano): Error the entire connection.
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment