Skip to content

Commit

Permalink
Fix for epoll backend: use duplicated fd (#75)
Browse files Browse the repository at this point in the history
# Description
While playing with cancellation on an old machine not supporting
`io_uring`, I noticed that it was using the original `fd`, thus causing
a `error.FileDescriptorNotRegistered` to appear.

# Solution
Use the duplicated `fd` if the `completion.flags.dup` boolean is set,
otherwise fallback to the `completion.fd` function.
  • Loading branch information
mitchellh authored Nov 7, 2023
2 parents 59e337c + efcd521 commit 04f21b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/backend/epoll.zig
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@ pub const Loop = struct {

fn stop_completion(self: *Loop, completion: *Completion) void {
// Delete. This should never fail.
if (completion.fd()) |fd| {
const maybe_fd = if (completion.flags.dup) completion.flags.dup_fd else completion.fd();
if (maybe_fd) |fd| {
std.os.epoll_ctl(
self.fd,
linux.EPOLL.CTL_DEL,
Expand Down

0 comments on commit 04f21b9

Please sign in to comment.