Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 May 2014 16:30:03 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265365 - head/usr.sbin/bhyve
Message-ID:  <201405051630.s45GU3LA079624@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Mon May  5 16:30:03 2014
New Revision: 265365
URL: http://svnweb.freebsd.org/changeset/base/265365

Log:
  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

Modified:
  head/usr.sbin/bhyve/mevent.c

Modified: head/usr.sbin/bhyve/mevent.c
==============================================================================
--- head/usr.sbin/bhyve/mevent.c	Mon May  5 16:19:24 2014	(r265364)
+++ head/usr.sbin/bhyve/mevent.c	Mon May  5 16:30:03 2014	(r265365)
@@ -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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405051630.s45GU3LA079624>