apple / apple/swift-system

IORing: `blockingConsumeCompletions()` drops context on error

Open
#364 0 comments 0 reactions 1 assignee Claimed by @glessard View on GitHub
Dominant language
Swift
Stars
1.4k
Forks
154
PR merge metrics
No merged PRs in 30d

Description

Issue exposed as a test case:
```swift
extension IORingTests {
func testMinimalContextLoss() throws {
var ring = try IORing(queueDepth: 4)
_ = try ring.submit(
linkedRequests: .close(FileDescriptor(rawValue: -1), context: 42)
)
var received: UInt64? = nil
ring.blockingConsumeCompletions { completion, _, _ in
received = completion?.context
}
XCTAssertEqual(received, 42) // fails: received is nil
}
}
```

The completion handler runs, but `completion` is nil so there is no relation to the initial request. If the `close()` operation had succeeded, `completion` would be non-nil and the context would be available.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.