dm: mevent: add edge triggered events.

Added edge triggered read and write events.
For mei mediator we need to detect changes in
sysfs files, it's not possible to do it via
level based triggers as the files are always
readable.

Tracked-On: #1417
Change-Id: Ib360ad31f30afa576b2b7b833f9bb139c269a030
Signed-off-by: Aviad Nissel <aviad.nissel@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Tomas Winkler 2018-10-09 10:35:53 +03:00 committed by wenlingz
parent f649beeb1d
commit e913f9e613
2 changed files with 13 additions and 2 deletions

View File

@ -122,9 +122,15 @@ mevent_kq_filter(struct mevent *mevp)
if (mevp->me_type == EVF_READ) if (mevp->me_type == EVF_READ)
retval = EPOLLIN; retval = EPOLLIN;
if (mevp->me_type == EVF_READ_ET)
retval = EPOLLIN | EPOLLET;
if (mevp->me_type == EVF_WRITE) if (mevp->me_type == EVF_WRITE)
retval = EPOLLOUT; retval = EPOLLOUT;
if (mevp->me_type == EVF_WRITE_ET)
retval = EPOLLOUT | EPOLLET;
return retval; return retval;
} }
@ -142,8 +148,11 @@ mevent_destroy(void)
ee.data.ptr = mevp; ee.data.ptr = mevp;
epoll_ctl(epoll_fd, EPOLL_CTL_DEL, mevp->me_fd, &ee); epoll_ctl(epoll_fd, EPOLL_CTL_DEL, mevp->me_fd, &ee);
if ((mevp->me_type == EVF_READ || mevp->me_type == EVF_WRITE) && if ((mevp->me_type == EVF_READ ||
mevp->me_fd != STDIN_FILENO) mevp->me_type == EVF_READ_ET ||
mevp->me_type == EVF_WRITE ||
mevp->me_type == EVF_WRITE_ET) &&
mevp->me_fd != STDIN_FILENO)
close(mevp->me_fd); close(mevp->me_fd);
free(mevp); free(mevp);

View File

@ -32,6 +32,8 @@
enum ev_type { enum ev_type {
EVF_READ, EVF_READ,
EVF_WRITE, EVF_WRITE,
EVF_READ_ET,
EVF_WRITE_ET,
EVF_TIMER, /* Not supported yet */ EVF_TIMER, /* Not supported yet */
EVF_SIGNAL /* Not supported yet */ EVF_SIGNAL /* Not supported yet */
}; };