Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -197,6 +197,9 @@ extension InlineStreamMultiplexer {
}
}

@available(*, unavailable)
extension InlineStreamMultiplexer: Sendable {}

extension NIOHTTP2Handler {
/// A multiplexer that creates a child channel for each HTTP/2 stream.
///
Expand Down
9 changes: 6 additions & 3 deletions Sources/NIOHTTP2/HTTP2CommonInboundStreamMultiplexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ internal class HTTP2CommonInboundStreamMultiplexer {
}
}

@available(*, unavailable)
extension HTTP2CommonInboundStreamMultiplexer: Sendable {}

// MARK:- inbound multiplexer functions
// note this is intentionally not bound to `HTTP2InboundStreamMultiplexer` to allow for freedom in modifying the shared driver function signatures
extension HTTP2CommonInboundStreamMultiplexer {
Expand Down Expand Up @@ -222,7 +225,7 @@ extension HTTP2CommonInboundStreamMultiplexer {
}

internal func selectivelyPropagateUserInboundEvent(context: ChannelHandlerContext, event: Any) {
func propagateEvent(_ event: Any) {
func propagateEvent(_ event: ChannelShouldQuiesceEvent) {
for channel in self.streams.values {
channel.baseChannel.pipeline.fireUserInboundEventTriggered(event)
}
Expand All @@ -232,8 +235,8 @@ extension HTTP2CommonInboundStreamMultiplexer {
}

switch event {
case is ChannelShouldQuiesceEvent:
propagateEvent(event)
case let shouldQuiesceEvent as ChannelShouldQuiesceEvent:
propagateEvent(shouldQuiesceEvent)
default:
()
}
Expand Down
3 changes: 0 additions & 3 deletions Sources/NIOHTTP2/HTTP2FrameParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1555,9 +1555,6 @@ struct FrameFlags: OptionSet, CustomStringConvertible {
/// on a new stream.
internal static let priority = FrameFlags(rawValue: 0x20)

// useful for test cases
internal static var allFlags: FrameFlags = [.endStream, .endHeaders, .padded, .priority]

internal var description: String {
var strings: [String] = []
for i in 0..<8 {
Expand Down
17 changes: 7 additions & 10 deletions Sources/NIOHTTP2/HTTP2StreamChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct HTTP2StreamChannelOptions: Sendable {

extension HTTP2StreamChannelOptions {
/// A namespace for the types used to represent HTTP/2 stream channel options.
public enum Types {}
public enum Types: Sendable {}
}

@available(*, deprecated, renamed: "HTTP2StreamChannelOptions.Types.StreamIDOption")
Expand Down Expand Up @@ -761,24 +761,21 @@ extension HTTP2StreamChannel {
while self.pendingReads.count > 0 {
let frame = self.pendingReads.removeFirst()

let anyStreamData: NIOAny
let dataLength: Int?

switch self.streamDataType {
case .frame:
anyStreamData = NIOAny(frame)
case .framePayload:
anyStreamData = NIOAny(frame.payload)
}

switch frame.payload {
case .data(let data):
dataLength = data.data.readableBytes
default:
dataLength = nil
}

self.pipeline.fireChannelRead(anyStreamData)
switch self.streamDataType {
case .frame:
self.pipeline.fireChannelRead(frame)
case .framePayload:
self.pipeline.fireChannelRead(frame.payload)
}

if let size = dataLength, let increment = self.windowManager.bufferedFrameEmitted(size: size) {
// To have a pending read, we must have a stream ID.
Expand Down
14 changes: 13 additions & 1 deletion Sources/NIOHTTP2/HTTP2ToHTTP1Codec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ public final class HTTP2ToHTTP1ClientCodec: ChannelInboundHandler, ChannelOutbou
}
}

@available(*, unavailable)
extension HTTP2ToHTTP1ClientCodec: Sendable {}

/// A simple channel handler that translates HTTP/2 concepts into HTTP/1 data types,
/// and vice versa, for use on the client side.
///
Expand All @@ -230,7 +233,7 @@ public final class HTTP2FramePayloadToHTTP1ClientCodec: ChannelInboundHandler, C
private var baseCodec: BaseClientCodec

/// The HTTP protocol scheme being used on this connection.
public enum HTTPProtocol {
public enum HTTPProtocol: Sendable, Hashable {
case https
case http
}
Expand Down Expand Up @@ -279,6 +282,9 @@ public final class HTTP2FramePayloadToHTTP1ClientCodec: ChannelInboundHandler, C
}
}

@available(*, unavailable)
extension HTTP2FramePayloadToHTTP1ClientCodec: Sendable {}

// MARK: - Server

private struct BaseServerCodec {
Expand Down Expand Up @@ -423,6 +429,9 @@ public final class HTTP2ToHTTP1ServerCodec: ChannelInboundHandler, ChannelOutbou
}
}

@available(*, unavailable)
extension HTTP2ToHTTP1ServerCodec: Sendable {}

/// A simple channel handler that translates HTTP/2 concepts into HTTP/1 data types,
/// and vice versa, for use on the server side.
///
Expand Down Expand Up @@ -475,6 +484,9 @@ public final class HTTP2FramePayloadToHTTP1ServerCodec: ChannelInboundHandler, C
}
}

@available(*, unavailable)
extension HTTP2FramePayloadToHTTP1ServerCodec: Sendable {}

extension HTTPMethod {
/// Create a `HTTPMethod` from the string representation of that method.
fileprivate init(methodString: String) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/NIOHTTP2/HTTP2UserEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension StreamClosedEvent: Hashable {}
/// A ``NIOHTTP2WindowUpdatedEvent`` is fired whenever a flow control window is changed.
/// This includes changes on the connection flow control window, which is signalled by
/// this event having ``streamID`` set to ``HTTP2StreamID/rootStream``.
public struct NIOHTTP2WindowUpdatedEvent {
public struct NIOHTTP2WindowUpdatedEvent: Sendable {
/// The stream ID of the window that has been changed. May be ``HTTP2StreamID/rootStream``, in which
/// case the connection window has changed.
public let streamID: HTTP2StreamID
Expand Down Expand Up @@ -85,7 +85,7 @@ public struct NIOHTTP2WindowUpdatedEvent {
extension NIOHTTP2WindowUpdatedEvent: Hashable {}

/// A ``NIOHTTP2StreamCreatedEvent`` is fired whenever a HTTP/2 stream is created.
public struct NIOHTTP2StreamCreatedEvent {
public struct NIOHTTP2StreamCreatedEvent: Sendable {
/// The ``HTTP2StreamID`` of the created stream.
public let streamID: HTTP2StreamID

Expand Down Expand Up @@ -114,7 +114,7 @@ extension NIOHTTP2StreamCreatedEvent: Hashable {}
///
/// This occurs when an `ACK` to a `SETTINGS` frame is received that changes the value of `SETTINGS_INITIAL_WINDOW_SIZE`. This is only fired
/// when the local peer has changed its settings.
public struct NIOHTTP2BulkStreamWindowChangeEvent {
public struct NIOHTTP2BulkStreamWindowChangeEvent: Sendable {
/// The change in the remote stream window sizes.
public let delta: Int

Expand Down
2 changes: 2 additions & 0 deletions Sources/NIOHTTP2/StreamMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ struct StreamMap<Element: PerStreamData> {
}
}

extension StreamMap: Sendable where Element: Sendable {}

extension StreamMap where Element == HTTP2StreamStateMachine {
// This function exists as a performance optimisation: we can keep track of the index and where we are, and
// thereby avoid searching the array twice.
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIOHTTP2/StreamStateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ import NIOHPACK
///
/// Operations on the state machine are performed by calling specific functions corresponding to
/// the operation that is about to occur.
struct HTTP2StreamStateMachine {
fileprivate enum State {
struct HTTP2StreamStateMachine: Sendable {
fileprivate enum State: Sendable {
// TODO(cory): Can we remove the idle state? Streams shouldn't sit in idle for long periods
// of time, they should immediately transition out, so can we avoid it entirely?
/// In the idle state, the stream has not been opened by either peer.
Expand Down