Skip to content

Commit

Permalink
call io_uring_prep_cancel() with zero flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Jan 17, 2024
1 parent 8939358 commit 8d0dd39
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions Sources/IORing/Submission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ import AsyncExtensions
import CIORingShims
import Glibc

// IORING_ASYNC_CANCEL_xxx not in our liburing
struct AsyncCancelFlags: OptionSet {
typealias RawValue = CInt

let rawValue: RawValue

init(rawValue: RawValue) {
self.rawValue = rawValue
}

static let all = AsyncCancelFlags(rawValue: 1 << 0)
static let fd = AsyncCancelFlags(rawValue: 1 << 1)
static let any = AsyncCancelFlags(rawValue: 1 << 2)
static let fdFixed = AsyncCancelFlags(rawValue: 1 << 3)
}

@IORingActor
class Submission<T: Sendable>: CustomStringConvertible {
// reference to owner which owns ring
Expand Down Expand Up @@ -115,7 +99,7 @@ class Submission<T: Sendable>: CustomStringConvertible {
do {
precondition(cancellationToken != nil)
let sqe = try ring.getSqe()
io_uring_prep_cancel(sqe, cancellationToken, AsyncCancelFlags.all.rawValue)
io_uring_prep_cancel(sqe, cancellationToken, 0)
try ring.submit()
} catch {
IORing.shared.logger.debug("failed to cancel submission \(self)")
Expand Down Expand Up @@ -530,6 +514,21 @@ enum IORingOperation: UInt32 {
case sendmsg_zc
}

struct AsyncCancelFlags: OptionSet {
typealias RawValue = CInt

let rawValue: RawValue

init(rawValue: RawValue) {
self.rawValue = rawValue
}

static let all = AsyncCancelFlags(rawValue: 1 << 0)
static let fd = AsyncCancelFlags(rawValue: 1 << 1)
static let any = AsyncCancelFlags(rawValue: 1 << 2)
static let fdFixed = AsyncCancelFlags(rawValue: 1 << 3)
}

extension Submission: Equatable {
public nonisolated static func == (lhs: Submission, rhs: Submission) -> Bool {
ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
Expand Down

0 comments on commit 8d0dd39

Please sign in to comment.