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

"Ghost" send callback in macOS (kqueue) #105

Open TheWaWaR opened 1 month ago

TheWaWaR commented 1 month ago

I'm writing a high performance MQTT benchmark tool with libxev, when I start 10000 MQTT client connections and setup the keep alive time to 5 seconds (send Pingreq message every 5s). The connecting process is ok, but after 5+ seconds later there maybe some "ghost" send callback happened with send operation. The "ghost" here means: after the callback been called and returned with a .disarm and then the callback will called again even without a loop.add().

Reproduce steps:

After some debug, the callback is called in kqueue.zig:434.

The source code is here. The libxev commit id used is: 1dd3c9015a542757b049f6d33beb8941f57bce1f

If I uncomment main.zig:291:

comp.* = .{};

There will be a op=noop log with a following panic.

NOTE: I also run this program in ARM64 Linux, with no problem.