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

Accept PING frames even when fully quiesced #455

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1169,16 +1169,13 @@ extension HTTP2ConnectionStateMachine {
// RFC 7540 that says that receiving PINGs with ACK flags set when no PING ACKs are expected is forbidden. This is
// very strange, but we allow it.
switch self.state {
case .prefaceReceived, .active, .locallyQuiesced, .remotelyQuiesced, .bothQuiescing, .quiescingPrefaceReceived:
case .prefaceReceived, .active, .locallyQuiesced, .remotelyQuiesced, .bothQuiescing, .quiescingPrefaceReceived, .fullyQuiesced:
return (.init(result: .succeed, effect: nil), ackFlagSet ? .nothing : .sendAck)

case .idle, .prefaceSent, .quiescingPrefaceSent:
// We're waiting for the remote preface.
return (.init(result: .connectionError(underlyingError: NIOHTTP2Errors.missingPreface(), type: .protocolError), effect: nil), .nothing)

case .fullyQuiesced:
return (.init(result: .connectionError(underlyingError: NIOHTTP2Errors.ioOnClosedConnection(), type: .protocolError), effect: nil), .nothing)

case .modifying:
preconditionFailure("Must not be left in modifying state")
}
Expand Down
4 changes: 3 additions & 1 deletion Tests/NIOHTTP2Tests/ConnectionStateMachineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,6 @@ class ConnectionStateMachineTests: XCTestCase {

// Connectiony things don't work either.
assertConnectionError(type: .protocolError, self.client.sendPing())
assertConnectionError(type: .protocolError, self.server.receivePing(ackFlagSet: false))
assertConnectionError(type: .protocolError, self.client.sendPriority())
assertConnectionError(type: .protocolError, self.server.receivePriority())
assertConnectionError(type: .protocolError, self.client.sendSettings([]))
Expand All @@ -1074,6 +1073,9 @@ class ConnectionStateMachineTests: XCTestCase {
// Duplicate goaway is cool though.
assertSucceeds(self.client.sendGoaway(lastStreamID: .rootStream))
assertSucceeds(self.server.receiveGoaway(lastStreamID: .rootStream))

// Receiving ping is cool too.
assertSucceeds(self.server.receivePing(ackFlagSet: false))
}

func testPushesAfterSendingPrefaceAreInvalid() {
Expand Down