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
2.07k stars 74 forks source link

kqueue: set proper errno for no threadpool, handle errnos properly #57

Closed mitchellh closed 1 year ago

mitchellh commented 1 year ago

Fixes #54

This fixes a few issues:

  1. When an operation requesting a threadpool is registered with a loop that has no threadpool, we set the result to EPERM. We were forgetting to negate the result so we were seeing it as a success.

  2. We used errno() to process results, but for manually constructed errnos (like the above), we'd read an invalid value because we don't actually set the errno threadlocal... and don't want to.

  3. We didn't have cancellation and permission denied as part of the error sets because we never hit them! Now we do! As we should.

penberg commented 1 year ago

Cool, thanks for the quick fix @mitchellh!