mirror of
https://github.com/apple/swift-nio
synced 2026-11-27 05:04:22 +00:00
Motivation: Currently the selector implementation just discards all pending events from the kernel when a deregistration has occurred during the event loop tick. This has been needed to not fail the test testWeDoNotDeliverEventsForPreviouslyClosedChannels. A cleanup case has been around for a while at: https://github.com/apple/swift-nio/issues/381 And when discussing this in https://github.com/apple/swift-nio/pull/1788 (to solve https://github.com/apple/swift-nio/issues/1761) we came to an agreement that the solution with tagging registrations on the backend would not suit only io_uring, but also solve the issue robustly for kqueue and epoll. Modification: Added sequenceIdentifier to the Registration and add support for it throughout. Mask in sequence identifier into user data in both kqueue and epoll. In kqueue, we just store the sequence identifier in the udata field (to support 32-bit properly). In epoll, where we know we have 64-bits, we mask it in together with fd. Removed all references to the old workaround from #381. Result: - New solution that doesn't need to discard all events when deregistrations are done during the event loop tick. - fixes #381