From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

poll: don't return POLLNVAL from poll_no_poll()

The trivial poll_no_poll() returned POLLNVAL if it got a bit it doesn't
recognize. This is wrong: poll() should ignore bits it doesn't recognize
and poll(1) states that POLLNVAL is only to be returned if the file
descriptor isn't open. This patch just drops the wrong test.

Before this patch, adding an extra bit not listed, like EPOLLRDHUP,
caused POLLNVAL to be returned. Worse, when using epoll, it did not
expect to ever get back POLLNVAL from poll(), and caused an assertion
failure.

Fixes #971.

Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/core/poll.cc b/core/poll.cc
--- a/core/poll.cc
+++ b/core/poll.cc
@@ -67,16 +67,7 @@ using namespace std;

 int poll_no_poll(int events)
 {
-    /*
-     * Return true for read/write.  If the user asked for something
-     * special, return POLLNVAL, so that clients have a way of
-     * determining reliably whether or not the extended
-     * functionality is present without hard-coding knowledge
-     * of specific filesystem implementations.
-     */
-    if (events & ~POLLSTANDARD)
-        return (POLLNVAL);
-
+     // Return ready for read/write.
     return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
 }

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to