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

Don't reset previously closed stream, since it's racy. #7922

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -649,7 +649,10 @@ class Http2Connection internal constructor(builder: Builder) : Closeable {
}
val dataStream = getStream(streamId)
if (dataStream == null) {
writeSynResetLater(streamId, ErrorCode.PROTOCOL_ERROR)
if (streamId > lastGoodStreamId) {
// TODO should be a connection error for a data frame on an idle stream
writeSynResetLater(streamId, ErrorCode.PROTOCOL_ERROR)
}
updateConnectionFlowControl(length.toLong())
source.skip(length.toLong())
return
Expand Down
Expand Up @@ -204,8 +204,7 @@ class Http2ConnectionTest {
assertThat(frame1.type).isEqualTo(Http2.TYPE_HEADERS)
val frame2 = peer.takeFrame()
assertThat(frame2.type).isEqualTo(Http2.TYPE_RST_STREAM)
val frame3 = peer.takeFrame()
assertThat(frame3.type).isEqualTo(Http2.TYPE_RST_STREAM)
assertThat(peer.pollFrame()).isNull()
assertThat(connection.readBytes.acknowledged).isEqualTo(0L)
assertThat(connection.readBytes.total).isEqualTo(2048L)
}
Expand Down
Expand Up @@ -87,6 +87,8 @@ class MockHttp2Peer : Closeable {

fun takeFrame(): InFrame = inFrames.take()

fun pollFrame(): InFrame? = inFrames.poll()

fun play() {
check(serverSocket == null)
serverSocket = ServerSocket()
Expand Down