-
Notifications
You must be signed in to change notification settings - Fork 813
Description
The current edge triggered behavior on Windows is not consistent with the behavior of EPOLLET in epoll or EV_CLEAR in kqueue. This can be seen with the following minimal example: https://github.com/sullivan-sean/mio-edge-triggered
On Windows, interests for a source are cleared on event receipt and reset on WouldBlock errors. If a source is polled until readable and then a read call is made this does not reset the interests. Another call to read after all data has been read (to throw WouldBlock) is necessary to reset interests.
Edge triggered behavior, as described in the epoll docs, "only delivers events when changes occur on the monitored file descriptor." There is a question of whether a partial read is actually considered a change on a file descriptor, i.e. is the Windows behavior still technically "edge-triggered" and in some ways more correct by waiting for WouldBlock to reset interests? In playing around with the epoll and kqueue behavior, it seems that even if only a small read is performed and there is still more data to be read, a subsequent poll will still emit a read-readiness event. This suggests that in practice short reads do reset "read-readiness" in edge-triggered mode.
For consistency, then, sources on Windows would need to reset interests on successful I/O and not just WouldBlock errors.