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

Fix compiling on 6.1 #3057

Merged
merged 6 commits into from
Jan 14, 2025
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
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ let package = Package(
"NIOConcurrencyHelpers",
"NIOEmbedded",
"CNIOLinux",
"CNIODarwin",
"NIOTLS",
]
),
Expand Down Expand Up @@ -558,7 +559,7 @@ let package = Package(
if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-system.git", from: "1.4.0"),
]
} else {
Expand Down
5 changes: 3 additions & 2 deletions Sources/NIOCore/EventLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,13 @@ extension EventLoop {
/// - Returns: An `EventLoopFuture` containing the result of `task`'s execution.
@inlinable
@preconcurrency
public func submit<T: Sendable>(_ task: @escaping @Sendable () throws -> T) -> EventLoopFuture<T> {
public func submit<T>(_ task: @escaping @Sendable () throws -> T) -> EventLoopFuture<T> {
let promise: EventLoopPromise<T> = makePromise(file: #fileID, line: #line)

self.execute {
do {
promise.succeed(try task())
// UnsafeUnchecked is allowed here because we know we are on the EL.
promise.assumeIsolatedUnsafeUnchecked().succeed(try task())
} catch let err {
promise.fail(err)
}
Expand Down
3 changes: 0 additions & 3 deletions Sources/NIOCore/FileRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ public struct FileRegion: Sendable {
}
}

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

extension FileRegion {
/// Create a new `FileRegion` forming a complete file.
///
Expand Down
9 changes: 5 additions & 4 deletions Sources/NIOEmbedded/AsyncTestingEventLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public final class NIOAsyncTestingEventLoop: EventLoop, @unchecked Sendable {
self.scheduledTasks.removeFirst { $0.id == taskID }
}

private func insertTask<ReturnType: Sendable>(
private func insertTask<ReturnType>(
taskID: UInt64,
deadline: NIODeadline,
promise: EventLoopPromise<ReturnType>,
Expand All @@ -145,7 +145,8 @@ public final class NIOAsyncTestingEventLoop: EventLoop, @unchecked Sendable {
insertOrder: self.nextTaskNumber(),
task: {
do {
promise.succeed(try task())
// UnsafeUnchecked is acceptable because we know we're in the loop here.
promise.assumeIsolatedUnsafeUnchecked().succeed(try task())
} catch let err {
promise.fail(err)
}
Expand All @@ -159,7 +160,7 @@ public final class NIOAsyncTestingEventLoop: EventLoop, @unchecked Sendable {
/// - see: `EventLoop.scheduleTask(deadline:_:)`
@discardableResult
@preconcurrency
public func scheduleTask<T: Sendable>(
public func scheduleTask<T>(
deadline: NIODeadline,
_ task: @escaping @Sendable () throws -> T
) -> Scheduled<T> {
Expand Down Expand Up @@ -201,7 +202,7 @@ public final class NIOAsyncTestingEventLoop: EventLoop, @unchecked Sendable {
/// - see: `EventLoop.scheduleTask(in:_:)`
@discardableResult
@preconcurrency
public func scheduleTask<T: Sendable>(in: TimeAmount, _ task: @escaping @Sendable () throws -> T) -> Scheduled<T> {
public func scheduleTask<T>(in: TimeAmount, _ task: @escaping @Sendable () throws -> T) -> Scheduled<T> {
self.scheduleTask(deadline: self.now + `in`, task)
}

Expand Down
13 changes: 9 additions & 4 deletions Sources/NIOHTTP1/HTTPDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
//
//===----------------------------------------------------------------------===//

@_implementationOnly import CNIOLLHTTP
import NIOCore

#if compiler(>=6.1)
glbrntt marked this conversation as resolved.
Show resolved Hide resolved
private import CNIOLLHTTP
#else
@_implementationOnly import CNIOLLHTTP
#endif

extension UnsafeMutablePointer where Pointee == llhttp_t {
/// Returns the `KeepAliveState` for the current message that is parsed.
fileprivate var keepAliveState: KeepAliveState {
Expand Down Expand Up @@ -631,7 +636,7 @@ public final class HTTPDecoder<In, Out>: ByteToMessageDecoder, HTTPDecoderDelega
self.url = String(decoding: bytes, as: Unicode.UTF8.self)
}

func didFinishHead(
fileprivate func didFinishHead(
versionMajor: Int,
versionMinor: Int,
isUpgrade: Bool,
Expand Down Expand Up @@ -815,7 +820,7 @@ extension HTTPParserError {
/// - Parameter fromCHTTPParserErrno: The error from the underlying library.
/// - Returns: The corresponding `HTTPParserError`, or `nil` if there is no
/// corresponding error.
static func httpError(fromCHTTPParserErrno: llhttp_errno_t) -> HTTPParserError? {
fileprivate static func httpError(fromCHTTPParserErrno: llhttp_errno_t) -> HTTPParserError? {
switch fromCHTTPParserErrno {
case HPE_INTERNAL:
return .invalidInternalState
Expand Down Expand Up @@ -874,7 +879,7 @@ extension HTTPMethod {
///
/// - Parameter httpParserMethod: The method returned by `http_parser`.
/// - Returns: The corresponding `HTTPMethod`.
static func from(httpParserMethod: llhttp_method) -> HTTPMethod {
fileprivate static func from(httpParserMethod: llhttp_method) -> HTTPMethod {
switch httpParserMethod {
case HTTP_DELETE:
return .DELETE
Expand Down
1 change: 1 addition & 0 deletions Sources/NIOPosix/DatagramVectorReadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import CNIODarwin
import CNIOLinux
import NIOCore

Expand Down
1 change: 1 addition & 0 deletions Sources/NIOPosix/PendingDatagramWritesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

import Atomics
import CNIODarwin
import CNIOLinux
import NIOCore

Expand Down
2 changes: 1 addition & 1 deletion Sources/NIOPosix/SelectableEventLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public protocol NIOEventLoopMetricsDelegate: Sendable {
/// The whole processing of I/O and tasks is done by a `NIOThread` that is tied to the `SelectableEventLoop`. This `NIOThread`
/// is guaranteed to never change!
@usableFromInline
internal final class SelectableEventLoop: EventLoop {
internal final class SelectableEventLoop: EventLoop, @unchecked Sendable {

static let strictModeEnabled: Bool = {
switch getenv("SWIFTNIO_STRICT").map({ String.init(cString: $0).lowercased() }) {
Expand Down
1 change: 1 addition & 0 deletions Sources/NIOPosix/SelectorKqueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

import NIOConcurrencyHelpers
import NIOCore

#if canImport(Darwin)
Expand Down
1 change: 1 addition & 0 deletions Tests/NIOPosixTests/HappyEyeballsTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

import CNIOLinux
import NIOEmbedded
import XCTest

Expand Down
2 changes: 1 addition & 1 deletion Tests/NIOPosixTests/MulticastTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import CNIOLinux
import NIOCore
import NIOPosix
import XCTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

import CNIODarwin
import CNIOLinux
import NIOEmbedded
import XCTest
Expand Down
Loading