FreeBSD/sys/geom/geom_event.c
/*
 * XXX: It might actually be useful to call this function with topology held.
 * XXX: This would ensure that the event gets created before anything else
 * XXX: changes.  At present all users have a handle on things in some other
 * XXX: way, so this remains an XXX for now.
 */
It might actually be useful to call this function with topology held.
XXX: This would ensure that the event gets created before anything else
XXX: changes.  At present all users have a handle on things in some other
XXX: way, so this remains an XXX for now.
It might actually be useful to call this function with topology held . XXX : This would ensure that the event gets created before anything else XXX : changes . At present all users have a handle on things in some other XXX : way so this remains an XXX for now .
int
g_waitfor_event(g_event_t *func, void *arg, int flag, ...)
{
	va_list ap;
	struct g_event *ep;
	int error;
	g_topology_assert_not();
	KASSERT(flag == M_WAITOK || flag == M_NOWAIT,
	    ("Wrong flag to g_post_event"));
	va_start(ap, flag);
	error = g_post_event_x(func, arg, flag, EV_WAKEUP, &ep, ap);
	va_end(ap);
	if (error)
		return (error);
	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);
}
int g_waitfor_event ( g_event_t * func , void * arg , int flag , ... ) { va_list ap ; struct g_event * ep ; int error ; g_topology_assert_not ( ) ; KASSERT ( flag == M_WAITOK || flag == M_NOWAIT , ( " " ) ) ; va_start ( ap , flag ) ; error = g_post_event_x ( func , arg , flag , EV_WAKEUP , & ep , ap ) ; va_end ( ap ) ; if ( error ) return ( error ) ; mtx_lock ( & g_eventlock ) ; while ( ! ( ep -> flag & EV_DONE ) ) msleep ( ep , & g_eventlock , PRIBIO , " " , hz ) ; if ( ep -> flag & EV_CANCELED ) error = EAGAIN ; mtx_unlock ( & g_eventlock ) ; g_free ( ep ) ; return ( error ) ; }
XXX: It might actually be useful to call this function with topology held.
XXX : It might actually be useful to call this function with topology held .