Skip to content

Commit

Permalink
enhanceYourCalm
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Nov 6, 2024
1 parent 62a4861 commit 920e6ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension HTTP2ServerConnectionManager {

enum ReceivedPingResult {
case sendPingAck(pingData: HTTP2PingData)
case enhanceYouCalmAndClose(lastStreamId: HTTP2StreamID) // Sent when client sends too many pings
case enhanceYourCalmAndClose(lastStreamId: HTTP2StreamID) // Sent when client sends too many pings
case none
}

Expand All @@ -104,7 +104,7 @@ extension HTTP2ServerConnectionManager {
let tooManyPings = activeState.keepalive.receivedPing(atTime: time, hasOpenStreams: activeState.openStreams.count > 0)
if tooManyPings {
self.state = .closed
return .enhanceYouCalmAndClose(lastStreamId: activeState.lastStreamId)
return .enhanceYourCalmAndClose(lastStreamId: activeState.lastStreamId)
} else {
self.state = .active(activeState)
return .sendPingAck(pingData: data)
Expand All @@ -114,7 +114,7 @@ extension HTTP2ServerConnectionManager {
let tooManyPings = closingState.keepalive.receivedPing(atTime: time, hasOpenStreams: closingState.openStreams.count > 0)
if tooManyPings {
self.state = .closed
return .enhanceYouCalmAndClose(lastStreamId: closingState.lastStreamId)
return .enhanceYourCalmAndClose(lastStreamId: closingState.lastStreamId)
} else {
self.state = .closing(closingState)
return .sendPingAck(pingData: data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ final class HTTP2ServerConnectionManager: ChannelDuplexHandler {
case .sendPingAck:
break // ping acks are sent by NIOHTTP2 channel handler

case .enhanceYouCalmAndClose(let lastStreamId):
case .enhanceYourCalmAndClose(let lastStreamId):
let goAway = HTTP2Frame(
streamID: .rootStream,
payload: .goAway(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class HTTP2ServerConnectionManagerStateMachineTests: XCTestCase {
pingResult = stateMachine.receivedPing(atTime: now + .seconds(1), data: pingData)
guard case .sendPingAck = pingResult else { XCTFail(); return }
pingResult = stateMachine.receivedPing(atTime: now + .seconds(2), data: pingData)
guard case .enhanceYouCalmAndClose(let id) = pingResult else { XCTFail(); return }
guard case .enhanceYourCalmAndClose(let id) = pingResult else { XCTFail(); return }
XCTAssertEqual(id, 4)
guard case .closed = stateMachine.state else { XCTFail(); return }
}
Expand Down

0 comments on commit 920e6ab

Please sign in to comment.