svn commit: r217443 - stable/7/sys/geom
Jaakko Heinonen
jh at FreeBSD.org
Sat Jan 15 09:36:32 UTC 2011
Author: jh
Date: Sat Jan 15 09:36:31 2011
New Revision: 217443
URL: http://svn.freebsd.org/changeset/base/217443
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/7/sys/geom/geom_event.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/geom/geom_event.c
==============================================================================
--- stable/7/sys/geom/geom_event.c Sat Jan 15 09:25:19 2011 (r217442)
+++ stable/7/sys/geom/geom_event.c Sat Jan 15 09:36:31 2011 (r217443)
@@ -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-stable-7
mailing list