casaroli opened a new pull request, #22431:
URL: https://github.com/apache/nuttx/pull/22431

   ## Summary
   
   Two poll/epoll results that differ from Linux:
   
   - `poll_notify()` cleared `POLLOUT` whenever `POLLERR` or `POLLHUP` was set. 
POSIX makes only `POLLHUP` and `POLLOUT` mutually exclusive; `POLLERR` may come 
with `POLLOUT`, and Linux reports both, for example for the write end of a pipe 
without readers (`pipe_poll()`: `EPOLLOUT | EPOLLERR`; `write()` fails with 
`EPIPE` at once). On NuttX the pipe driver sets `POLLOUT | POLLERR` for that 
pipe (pipe_common.c), and `poll_notify()` removed the `POLLOUT`: a writer that 
waits only for `POLLOUT` (with epoll, or poll() with `POLLOUT` alone) saw 
`POLLERR` alone. Commit 1 clears `POLLOUT` only for `POLLHUP`, and fixes the 
pipe driver comment that said "Change POLLOUT to POLLERR".
   - `epoll_ctl()` with `EPOLL_CTL_DEL` or `EPOLL_CTL_MOD` for an fd that is 
not in the set returned 0. Linux gives `ENOENT`. Commit 2 returns `-ENOENT` 
when no list of the epoll set has the fd.
   
   The test cases are in apache/nuttx-apps#NNNN.
   
   ## Impact
   
   poll() and epoll report `POLLOUT | POLLERR` where they reported `POLLERR` 
alone; `POLLHUP` still removes `POLLOUT`. A program that took "POLLERR without 
POLLOUT" as "not writable" now also sees `POLLOUT`; `write()` then fails with 
the error at once, as on Linux. `EPOLL_CTL_DEL` / `EPOLL_CTL_MOD` of an fd that 
is not in the set now fail with `ENOENT`; no in-tree caller (nuttx, apps) 
depends on the 0. No API, ABI or Kconfig change. The same in all build modes 
and on all architectures.
   
   ## Testing
   
   `cmocka_epoll` with the new cases `epoll04` (DEL and MOD of an fd not in the 
set) and `epoll05` (pipe without readers: poll() and epoll_wait()), 
qemu-armv8a:nsh (flat, CI image gcc 12.3, QEMU TCG):
   
   | | master | this PR |
   |---|---|---|
   | epoll04 | FAIL: `0 != -1` (DEL returns 0) | pass |
   | epoll05 | FAIL: `8 != 12` (revents `POLLERR` alone) | pass |
   
   epoll01 to epoll03 fail on master and with this PR in the same way under 
QEMU TCG (a timing range of 2 ticks, and the cases after it); they do not touch 
the changed code.
   
   Builds with `-Werror`: qemu-armv8a:nsh, qemu-armv8a:knsh (kernel), 
rv-virt:nsh64, rv-virt:knsh64 (kernel), rv-virt:netnsh with `cmocka_epoll`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] fs/vfs: Fix two poll and... casaroli (via GitHub) via commits

Reply via email to