From e913f9e613317a0126239f30df56285744e2fc39 Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Tue, 9 Oct 2018 10:35:53 +0300 Subject: [PATCH] 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 Signed-off-by: Tomas Winkler Acked-by: Yu Wang --- devicemodel/core/mevent.c | 13 +++++++++++-- devicemodel/include/mevent.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/devicemodel/core/mevent.c b/devicemodel/core/mevent.c index c5c1f3b29..816c4288d 100644 --- a/devicemodel/core/mevent.c +++ b/devicemodel/core/mevent.c @@ -122,9 +122,15 @@ mevent_kq_filter(struct mevent *mevp) if (mevp->me_type == EVF_READ) retval = EPOLLIN; + if (mevp->me_type == EVF_READ_ET) + retval = EPOLLIN | EPOLLET; + if (mevp->me_type == EVF_WRITE) retval = EPOLLOUT; + if (mevp->me_type == EVF_WRITE_ET) + retval = EPOLLOUT | EPOLLET; + return retval; } @@ -142,8 +148,11 @@ mevent_destroy(void) ee.data.ptr = mevp; epoll_ctl(epoll_fd, EPOLL_CTL_DEL, mevp->me_fd, &ee); - if ((mevp->me_type == EVF_READ || mevp->me_type == EVF_WRITE) && - mevp->me_fd != STDIN_FILENO) + if ((mevp->me_type == EVF_READ || + 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); free(mevp); diff --git a/devicemodel/include/mevent.h b/devicemodel/include/mevent.h index 6ae4a41a0..0aa7ab3a0 100644 --- a/devicemodel/include/mevent.h +++ b/devicemodel/include/mevent.h @@ -32,6 +32,8 @@ enum ev_type { EVF_READ, EVF_WRITE, + EVF_READ_ET, + EVF_WRITE_ET, EVF_TIMER, /* Not supported yet */ EVF_SIGNAL /* Not supported yet */ };