ext/inc/epoll.h in nyara-0.0.1.pre.3 vs ext/inc/epoll.h in nyara-0.0.1.pre.4
- old
+ new
@@ -6,10 +6,13 @@
static struct epoll_event qevents[MAX_E];
static void ADD_E(int fd, uint64_t etype) {
struct epoll_event e;
+ // not using edge trigger flag EPOLLET
+ // because edge trigger only fire once when fd is readable/writable
+ // but the event may not be consumed in our handler
e.events = EPOLLIN | EPOLLOUT;
e.data.u64 = (etype << 32) | (uint64_t)fd;
// todo timeout
# ifdef NDEBUG
@@ -18,12 +21,11 @@
if (epoll_ctl(qfd, EPOLL_CTL_ADD, fd, &e))
printf("%s: %s\n", __func__, strerror(errno));
# endif
}
-// either epoll or kqueue removes the event watch from queue when fd closed
-// seems this is not required in epoll?
+// NOTE either epoll or kqueue removes the event watch from queue when fd closed
static void DEL_E(int fd) {
struct epoll_event e;
e.events = EPOLLIN | EPOLLOUT;
e.data.ptr = NULL;
@@ -36,11 +38,10 @@
}
static void INIT_E() {
qfd = epoll_create(10); // size not important
if (qfd == -1) {
- printf("%s\n", strerror(errno));
- exit(-1);
+ rb_sys_fail("epoll_create(2)");
}
}
static void LOOP_E() {
while (1) {