mitchellh / libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
MIT License
1.97k stars 65 forks source link

Fix for `epoll` backend: use duplicated `fd` #75

Closed Corendos closed 10 months ago

Corendos commented 10 months ago

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.

mitchellh commented 10 months ago

Thanks!