svn commit: r217392 - stable/8/sys/geom
Jaakko Heinonen
jh at FreeBSD.org
Fri Jan 14 11:12:56 UTC 2011
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);
}
More information about the svn-src-all
mailing list