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

epoll: don't pass unknown bits to poll()

Our epoll implementation is based on poll(). We should only pass to poll
the event bits we know are identical between epoll and poll(). In particular,
EPOLLET and EPOLLONESHOT shouldn't be passed to poll().

Before this patch we passed EPOLLET and EPOLLONESHOT on to poll(), which
could confuse poll() inplementations, and in particular poll_no_poll()
which caused an assertion failure.

Refs #971.

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

---
diff --git a/core/epoll.cc b/core/epoll.cc
--- a/core/epoll.cc
+++ b/core/epoll.cc
@@ -33,20 +33,19 @@ TRACEPOINT(trace_epoll_ready, "fd=%d file=%p, event=0x%x", int, file*, int);
 // We implement epoll using poll(), and therefore need to convert epoll's
 // event bits to and poll(). These are mostly the same, so the conversion
 // is trivial, but we verify this here with static_asserts. We additionally
-// support the epoll-only EPOLLET and EPOLLONESHOT.
+// support the epoll-only EPOLLET and EPOLLONESHOT, but those are not passed
+// on to poll() who wouldn't know what to do with them.
 static_assert(POLLIN == EPOLLIN, "POLLIN!=EPOLLIN");
 static_assert(POLLOUT == EPOLLOUT, "POLLOUT!=EPOLLOUT");
 static_assert(POLLRDHUP == EPOLLRDHUP, "POLLRDHUP!=EPOLLRDHUP");
 static_assert(POLLPRI == EPOLLPRI, "POLLPRI!=EPOLLPRI");
 static_assert(POLLERR == EPOLLERR, "POLLERR!=EPOLLERR");
 static_assert(POLLHUP == EPOLLHUP, "POLLHUP!=EPOLLHUP");
 constexpr int SUPPORTED_EVENTS =
-        EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLPRI | EPOLLERR | EPOLLHUP |
-        EPOLLET | EPOLLONESHOT;
+        EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLPRI | EPOLLERR | EPOLLHUP;
 inline uint32_t events_epoll_to_poll(uint32_t e)
 {
-    assert (!(e & ~SUPPORTED_EVENTS));
-    return e;
+    return e & SUPPORTED_EVENTS;
 }
 inline uint32_t events_poll_to_epoll(uint32_t e)
 {

--
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