diff options
author | neel <neel@FreeBSD.org> | 2014-05-05 16:30:03 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2014-05-05 16:30:03 +0000 |
commit | 08f11e3e21eb911b00bda0ec0ebaf259fdca2fde (patch) | |
tree | f2b6904ed620d2df621a56f3d58e2f383bc9cd66 /usr.sbin | |
parent | 5fd692c3b580554aa0926a4aa512022b56575d31 (diff) | |
download | FreeBSD-src-08f11e3e21eb911b00bda0ec0ebaf259fdca2fde.zip FreeBSD-src-08f11e3e21eb911b00bda0ec0ebaf259fdca2fde.tar.gz |
Re-adding an event to a kqueue modifies the parameters of the original event.
However, if the original knote had been disabled then it is not automatically
re-enabled.
Fix this by using EV_ADD to create an mevent and EV_ENABLE to enable it.
Adding a kevent for the first time implicitly enables it so existing callers
of mevent_add() don't need to change.
Reviewed by: grehan
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/mevent.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/bhyve/mevent.c b/usr.sbin/bhyve/mevent.c index b83ec69..07d3baf 100644 --- a/usr.sbin/bhyve/mevent.c +++ b/usr.sbin/bhyve/mevent.c @@ -52,9 +52,10 @@ __FBSDID("$FreeBSD$"); #define MEVENT_MAX 64 -#define MEV_ENABLE 1 -#define MEV_DISABLE 2 -#define MEV_DEL_PENDING 3 +#define MEV_ADD 1 +#define MEV_ENABLE 2 +#define MEV_DISABLE 3 +#define MEV_DEL_PENDING 4 extern char *vmname; @@ -147,10 +148,11 @@ mevent_kq_flags(struct mevent *mevp) int ret; switch (mevp->me_state) { + case MEV_ADD: + ret = EV_ADD; /* implicitly enabled */ + break; case MEV_ENABLE: - ret = EV_ADD; - if (mevp->me_type == EVF_TIMER) - ret |= EV_ENABLE; + ret = EV_ENABLE; break; case MEV_DISABLE: ret = EV_DISABLE; @@ -158,6 +160,9 @@ mevent_kq_flags(struct mevent *mevp) case MEV_DEL_PENDING: ret = EV_DELETE; break; + default: + assert(0); + break; } return (ret); @@ -284,7 +289,7 @@ mevent_add(int tfd, enum ev_type type, LIST_INSERT_HEAD(&change_head, mevp, me_list); mevp->me_cq = 1; - mevp->me_state = MEV_ENABLE; + mevp->me_state = MEV_ADD; mevent_notify(); exit: |