From f3641e67cbc934d66f241ceced3a3024565c4d12 Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Sat, 13 Sep 2025 17:37:15 -0700 Subject: [PATCH] Undo accidental revert of commits (#289) #288 accidentally reverted #282 and #284. --- Sources/Containerization/ContainerManager.swift | 7 ++----- .../Image/ImageStore/ImageStore+Export.swift | 6 +++--- .../Image/ImageStore/ImageStore+Import.swift | 10 +++++----- Sources/Containerization/NATNetworkInterface.swift | 1 + Sources/Containerization/UnixSocketRelay.swift | 2 ++ .../Containerization/VZVirtualMachineInstance.swift | 1 + Sources/ContainerizationOS/AsyncSignalHandler.swift | 1 + Sources/Integration/ProcessTests.swift | 1 + 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Sources/Containerization/ContainerManager.swift b/Sources/Containerization/ContainerManager.swift index 69c3edd3..9d9ddb63 100644 --- a/Sources/Containerization/ContainerManager.swift +++ b/Sources/Containerization/ContainerManager.swift @@ -45,6 +45,7 @@ public struct ContainerManager: Sendable { @available(macOS 26.0, *) public struct VmnetNetwork: Network { private var allocator: Allocator + // `reference` isn't used concurrently. nonisolated(unsafe) private let reference: vmnet_network_ref /// The IPv4 subnet of this network. @@ -94,6 +95,7 @@ public struct ContainerManager: Sendable { public let gateway: String? public let macAddress: String? + // `reference` isn't used concurrently. nonisolated(unsafe) private let reference: vmnet_network_ref public init( @@ -478,9 +480,4 @@ extension CIDRAddress { } } -@available(macOS 26.0, *) -private struct SendableReference: Sendable { - nonisolated(unsafe) private let reference: vmnet_network_ref -} - #endif diff --git a/Sources/Containerization/Image/ImageStore/ImageStore+Export.swift b/Sources/Containerization/Image/ImageStore/ImageStore+Export.swift index 43eff952..92e520c9 100644 --- a/Sources/Containerization/Image/ImageStore/ImageStore+Export.swift +++ b/Sources/Containerization/Image/ImageStore/ImageStore+Export.swift @@ -24,14 +24,14 @@ import Crypto import Foundation extension ImageStore { - internal struct ExportOperation { + public struct ExportOperation: Sendable { let name: String let tag: String let contentStore: ContentStore let client: ContentClient let progress: ProgressHandler? - init(name: String, tag: String, contentStore: ContentStore, client: ContentClient, progress: ProgressHandler? = nil) { + public init(name: String, tag: String, contentStore: ContentStore, client: ContentClient, progress: ProgressHandler? = nil) { self.contentStore = contentStore self.client = client self.progress = progress @@ -40,7 +40,7 @@ extension ImageStore { } @discardableResult - internal func export(index: Descriptor, platforms: (Platform) -> Bool) async throws -> Descriptor { + public func export(index: Descriptor, platforms: (Platform) -> Bool) async throws -> Descriptor { var pushQueue: [[Descriptor]] = [] var current: [Descriptor] = [index] while !current.isEmpty { diff --git a/Sources/Containerization/Image/ImageStore/ImageStore+Import.swift b/Sources/Containerization/Image/ImageStore/ImageStore+Import.swift index 7dc4eb4a..1adfedf5 100644 --- a/Sources/Containerization/Image/ImageStore/ImageStore+Import.swift +++ b/Sources/Containerization/Image/ImageStore/ImageStore+Import.swift @@ -22,7 +22,7 @@ import ContainerizationOCI import Foundation extension ImageStore { - internal struct ImportOperation { + public struct ImportOperation: Sendable { static let decoder = JSONDecoder() let client: ContentClient @@ -31,7 +31,7 @@ extension ImageStore { let progress: ProgressHandler? let name: String - init(name: String, contentStore: ContentStore, client: ContentClient, ingestDir: URL, progress: ProgressHandler? = nil) { + public init(name: String, contentStore: ContentStore, client: ContentClient, ingestDir: URL, progress: ProgressHandler? = nil) { self.client = client self.ingestDir = ingestDir self.contentStore = contentStore @@ -40,7 +40,7 @@ extension ImageStore { } /// Pull the required image layers for the provided descriptor and platform(s) into the given directory using the provided client. Returns a descriptor to the Index manifest. - internal func `import`(root: Descriptor, matcher: (ContainerizationOCI.Platform) -> Bool) async throws -> Descriptor { + public func `import`(root: Descriptor, matcher: (ContainerizationOCI.Platform) -> Bool) async throws -> Descriptor { var toProcess = [root] while !toProcess.isEmpty { // Count the total number of blobs and their size @@ -123,14 +123,14 @@ extension ImageStore { for _ in 0..<8 { if let desc = iterator.next() { group.addTask { - try await fetch(desc) + try await self.fetch(desc) } } } for try await _ in group { if let desc = iterator.next() { group.addTask { - try await fetch(desc) + try await self.fetch(desc) } } } diff --git a/Sources/Containerization/NATNetworkInterface.swift b/Sources/Containerization/NATNetworkInterface.swift index 825d3cc0..845fc8f3 100644 --- a/Sources/Containerization/NATNetworkInterface.swift +++ b/Sources/Containerization/NATNetworkInterface.swift @@ -31,6 +31,7 @@ public final class NATNetworkInterface: Interface, Sendable { public let macAddress: String? @available(macOS 26, *) + // `reference` isn't used concurrently. public nonisolated(unsafe) let reference: vmnet_network_ref! @available(macOS 26, *) diff --git a/Sources/Containerization/UnixSocketRelay.swift b/Sources/Containerization/UnixSocketRelay.swift index d9ae971f..0cd75419 100644 --- a/Sources/Containerization/UnixSocketRelay.swift +++ b/Sources/Containerization/UnixSocketRelay.swift @@ -267,6 +267,7 @@ extension SocketRelay { ) } + // `buf1` isn't used concurrently. nonisolated(unsafe) let buf1 = UnsafeMutableBufferPointer.allocate(capacity: Int(getpagesize())) connSource.setEventHandler { Self.fdCopyHandler( @@ -278,6 +279,7 @@ extension SocketRelay { } nonisolated(unsafe) let buf2 = UnsafeMutableBufferPointer.allocate(capacity: Int(getpagesize())) + // `buf2` isn't used concurrently. vsockConnectionSource.setEventHandler { Self.fdCopyHandler( buffer: buf2, diff --git a/Sources/Containerization/VZVirtualMachineInstance.swift b/Sources/Containerization/VZVirtualMachineInstance.swift index 72155fc3..0046bc18 100644 --- a/Sources/Containerization/VZVirtualMachineInstance.swift +++ b/Sources/Containerization/VZVirtualMachineInstance.swift @@ -68,6 +68,7 @@ struct VZVirtualMachineInstance: VirtualMachineInstance, Sendable { } } + // `vm` isn't used concurrently. private nonisolated(unsafe) let vm: VZVirtualMachine private let queue: DispatchQueue private let group: MultiThreadedEventLoopGroup diff --git a/Sources/ContainerizationOS/AsyncSignalHandler.swift b/Sources/ContainerizationOS/AsyncSignalHandler.swift index 895a1503..5f2fd328 100644 --- a/Sources/ContainerizationOS/AsyncSignalHandler.swift +++ b/Sources/ContainerizationOS/AsyncSignalHandler.swift @@ -53,6 +53,7 @@ public final class AsyncSignalHandler: Sendable { struct State: Sendable { var conts: [AsyncStream.Continuation] = [] + // `sources` isn't used concurrently. nonisolated(unsafe) var sources: [any DispatchSourceSignal] = [] } diff --git a/Sources/Integration/ProcessTests.swift b/Sources/Integration/ProcessTests.swift index 7030cbe6..f8a46689 100644 --- a/Sources/Integration/ProcessTests.swift +++ b/Sources/Integration/ProcessTests.swift @@ -62,6 +62,7 @@ extension IntegrationSuite { } final class BufferWriter: Writer { + // `data` isn't used concurrently. nonisolated(unsafe) var data = Data() func write(_ data: Data) throws {