Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2011 11:12:56 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r217392 - stable/8/sys/geom
Message-ID:  <201101141112.p0EBCuGl085861@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Fri Jan 14 11:12:56 2011
New Revision: 217392
URL: http://svn.freebsd.org/changeset/base/217392

Log:
  MFC r214748:
  
  Extend the g_eventlock mutex coverage in one_event() to include setting
  of the EV_DONE flag and use the mutex to protect against losing wakeups
  in g_waitfor_event().

Modified:
  stable/8/sys/geom/geom_event.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/geom/geom_event.c
==============================================================================
--- stable/8/sys/geom/geom_event.c	Fri Jan 14 10:56:44 2011	(r217391)
+++ stable/8/sys/geom/geom_event.c	Fri Jan 14 11:12:56 2011	(r217392)
@@ -212,11 +212,12 @@ one_event(void)
 	g_topology_assert();
 	mtx_lock(&g_eventlock);
 	TAILQ_REMOVE(&g_events, ep, events);
-	mtx_unlock(&g_eventlock);
 	if (ep->flag & EV_WAKEUP) {
 		ep->flag |= EV_DONE;
+		mtx_unlock(&g_eventlock);
 		wakeup(ep);
 	} else {
+		mtx_unlock(&g_eventlock);
 		g_free(ep);
 	}
 	g_topology_unlock();
@@ -355,11 +356,14 @@ g_waitfor_event(g_event_t *func, void *a
 	va_end(ap);
 	if (error)
 		return (error);
-	do 
-		tsleep(ep, PRIBIO, "g_waitfor_event", hz);
-	while (!(ep->flag & EV_DONE));
+
+	mtx_lock(&g_eventlock);
+	while (!(ep->flag & EV_DONE))
+		msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz);
 	if (ep->flag & EV_CANCELED)
 		error = EAGAIN;
+	mtx_unlock(&g_eventlock);
+
 	g_free(ep);
 	return (error);
 }



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