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

Fix loop active count in kqueue backend for cancellations #45

Closed ianic closed 1 year ago

ianic commented 1 year ago

I started tcp server which runs accept loop. In idle state there is one active completion, those with accept operation. I tried to cancel that operation and although got both callback; of the accept and of the cancel loop(.until_done) did not finish because loop.active is 1 not 0. It seems that non timer cancelations are not handling loop.active counter correctly.

I'm not absolutely sure that line 885 is the right place to decrement active count...

penberg commented 1 year ago

@mitchellh The fix looks correct to me and there's a test to prove it so please consider merging it.

mitchellh commented 1 year ago

Thanks for the reminder. I was I think on vacation May 16th so I just lost this in the noise... I'm heading to bed now but have this open as a tab on my desktop to remind me in the morning.