mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Motivation: We had a number of problems: 1. We wanted to lazily process input EOFs and connection resets only when the user actually calls `read()`. On Linux however you cannot unsubscribe from `EPOLLHUP` so that's not possible. 2. Lazily processing input EOFs/connection resets wastes kernel resources and that could potentially lead to a DOS 3. The very low-level `Selector` interpreted the eventing mechanism's events quite a lot so the `EventLoop`/`Channel` only ever saw `readable` or `writable` without further information what exactly happened. 4. We completely ignored `EPOLLHUP` until now which on Unix Domain Socket close leads to a 100% CPU spin (issue #277) Modifications: - made the `Selector` interface richer, it now sends the following events: `readable`, `writable`, `readEOF` (input EOF), `reset` (connection reset or some error) - process input EOFs and connection resets/errors eagerly - change all tests which relied on using unconnected and unbound sockets to user connected/bound ones as `epoll_wait` otherwise would keep sending us a stream of `EPOLLHUP`s which would now lead to an eager close Result: - most importantly: fix issue #277 - waste less kernel resources (by dealing with input EOFs/connection resets eagerly) - bring kqueue/epoll more in line