]> rtime.felk.cvut.cz Git - sojka/libev.git/commitdiff
Add experimental support for EPOLLPRI to the epoll backend epollpri
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Aug 2017 15:30:00 +0000 (17:30 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Aug 2017 15:30:00 +0000 (17:30 +0200)
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
ev++.h
ev.h
ev_epoll.c

diff --git a/ev++.h b/ev++.h
index 4f0a36ab029d7f433792157644dcc07e59b7ae7e..28a45fad4518d05943276263c700782c6fb1341c 100644 (file)
--- a/ev++.h
+++ b/ev++.h
@@ -63,6 +63,7 @@ namespace ev {
     NONE     = EV_NONE,
     READ     = EV_READ,
     WRITE    = EV_WRITE,
+    EXCEPTION= EV_EXCEPTION,
 #if EV_COMPAT3
     TIMEOUT  = EV_TIMEOUT,
 #endif
diff --git a/ev.h b/ev.h
index db9377765e76dfae7ca743a5daa35add1e77e663..9f0842dc019f7a53c6a7ef2bb70c1b43dd7491c5 100644 (file)
--- a/ev.h
+++ b/ev.h
@@ -219,6 +219,7 @@ enum {
   EV_NONE     =            0x00, /* no events */
   EV_READ     =            0x01, /* ev_io detected read will not block */
   EV_WRITE    =            0x02, /* ev_io detected write will not block */
+  EV_EXCEPTION=            0x04, /* ev_io detected exceptional condition */
   EV__IOFDSET =            0x80, /* internal use only */
   EV_IO       =         EV_READ, /* alias for type-detection */
   EV_TIMER    =      0x00000100, /* timer timed out */
index 6aef8622284d3fb744cb2e7acc9468e2ee0b82d5..02112c7ea69a7d47157cb9dc86bb7d5a10d3f51f 100644 (file)
@@ -91,7 +91,8 @@ epoll_modify (EV_P_ int fd, int oev, int nev)
   ev.data.u64 = (uint64_t)(uint32_t)fd
               | ((uint64_t)(uint32_t)++anfds [fd].egen << 32);
   ev.events   = (nev & EV_READ  ? EPOLLIN  : 0)
-              | (nev & EV_WRITE ? EPOLLOUT : 0);
+              | (nev & EV_WRITE ? EPOLLOUT : 0)
+              | (nev & EV_EXCEPTION ? EPOLLPRI : 0);
 
   if (expect_true (!epoll_ctl (backend_fd, oev && oldmask != nev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev)))
     return;
@@ -168,7 +169,8 @@ epoll_poll (EV_P_ ev_tstamp timeout)
       int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */
       int want = anfds [fd].events;
       int got  = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0)
-               | (ev->events & (EPOLLIN  | EPOLLERR | EPOLLHUP) ? EV_READ  : 0);
+               | (ev->events & (EPOLLIN  | EPOLLERR | EPOLLHUP) ? EV_READ  : 0)
+               | (ev->events & (EPOLLPRI | EPOLLERR | EPOLLHUP) ? EV_EXCEPTION : 0);
 
       /*
        * check for spurious notification.
@@ -197,7 +199,8 @@ epoll_poll (EV_P_ ev_tstamp timeout)
            * but we closed it).
            */
           ev->events = (want & EV_READ  ? EPOLLIN  : 0)
-                     | (want & EV_WRITE ? EPOLLOUT : 0);
+                     | (want & EV_WRITE ? EPOLLOUT : 0)
+                     | (want & EV_EXCEPTION ? EPOLLPRI : 0);
 
           /* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */
           /* which is fortunately easy to do for us. */