mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-03 12:49:45 +00:00
dm: mevent: implement enable/disable functions
Current mevent mevent_del/add() implementations are incomplete and buggy. It's easier to implement mevent_enable/disable() required for mei virtualization. Other user of these functions, which were previously empty stubs is the uart mediator, so far it looks working well. Add few style issues fix on the way. Tracked-On: #1416 Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
018aba944f
commit
f649beeb1d
@ -30,7 +30,6 @@
|
||||
* Micro event library for FreeBSD, designed for a single i/o thread
|
||||
* using EPOLL, and having events be persistent by default.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
@ -125,11 +124,12 @@ mevent_kq_filter(struct mevent *mevp)
|
||||
|
||||
if (mevp->me_type == EVF_WRITE)
|
||||
retval = EPOLLOUT;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
mevent_destroy()
|
||||
mevent_destroy(void)
|
||||
{
|
||||
struct mevent *mevp, *tmpp;
|
||||
struct epoll_event ee;
|
||||
@ -142,9 +142,8 @@ mevent_destroy()
|
||||
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_WRITE) &&
|
||||
mevp->me_fd != STDIN_FILENO)
|
||||
close(mevp->me_fd);
|
||||
|
||||
free(mevp);
|
||||
@ -221,13 +220,42 @@ mevent_add(int tfd, enum ev_type type,
|
||||
int
|
||||
mevent_enable(struct mevent *evp)
|
||||
{
|
||||
return 0;
|
||||
int ret;
|
||||
struct epoll_event ee;
|
||||
struct mevent *lp, *mevp = NULL;
|
||||
|
||||
mevent_qlock();
|
||||
/* Verify that the fd/type tuple is not present in the list */
|
||||
LIST_FOREACH(lp, &global_head, me_list) {
|
||||
if (lp == evp) {
|
||||
mevp = lp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mevent_qunlock();
|
||||
|
||||
if (!mevp)
|
||||
return -1;
|
||||
|
||||
ee.events = mevent_kq_filter(mevp);
|
||||
ee.data.ptr = mevp;
|
||||
ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, mevp->me_fd, &ee);
|
||||
if (ret < 0 && errno == EEXIST)
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
mevent_disable(struct mevent *evp)
|
||||
{
|
||||
return 0;
|
||||
int ret;
|
||||
|
||||
ret = epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evp->me_fd, NULL);
|
||||
if (ret < 0 && errno == ENOENT)
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user