romange / helio

A modern framework for backend development based on io_uring Linux interface
Apache License 2.0
447 stars 50 forks source link

fix: wake kqueue socket on shutdown #114

Closed andydunstall closed 1 year ago

andydunstall commented 1 year ago

As mentioned in https://github.com/romange/helio/pull/111, shutdown doesn't seem to wake up the socket accept fiber (can't find any reference to this but running locally getting the same behaviour, wheras epoll is woken)

With this the accept server tests pass ok as the accept fiber no longer blocks on tear down (theres some other failures on MacOS but they seem unrelatex)

This seemed simpler than using EVFILT_USER since AFAICT the trigger must include the centries_ index, which the socket doesn't know, and it requires calling back to the proactor, which notifies the kqueue, which calls Wakey, so seemed easier just to call directly? It is still a bit hacky - the #ifndef __linux__ is probably redundant but figured better to include to be safe