FreeBSD/sys/kern/kern_lockf.c
/*
 * Walk the list of locks for the file and create an out-going edge
 * from lock to each blocking lock.
 */
Walk the list of locks for the file and create an out-going edge
from lock to each blocking lock.
Walk the list of locks for the file and create an out - going edge from lock to each blocking lock .
static int
lf_add_outgoing(struct lockf *state, struct lockf_entry *lock)
{
	struct lockf_entry *overlap;
	int error;
	LIST_FOREACH(overlap, &state->ls_active, lf_link) {
		if (overlap->lf_start > lock->lf_end)
			break;
		if (!lf_blocks(lock, overlap))
			continue;
		error = lf_add_edge(lock, overlap);
		if (error) {
			lf_remove_outgoing(lock);
			return (error);
		}
	}
	LIST_FOREACH(overlap, &state->ls_pending, lf_link) {
		if (!lf_blocks(lock, overlap))
			continue;
		error = lf_add_edge(lock, overlap);
		if (error) {
			lf_remove_outgoing(lock);
			return (error);
		}
	}
	return (0);
}
static int lf_add_outgoing ( struct lockf * state , struct lockf_entry * lock ) { struct lockf_entry * overlap ; int error ; LIST_FOREACH ( overlap , & state -> ls_active , lf_link ) { if ( overlap -> lf_start > lock -> lf_end ) break ; if ( ! lf_blocks ( lock , overlap ) ) continue ; error = lf_add_edge ( lock , overlap ) ; if ( error ) { lf_remove_outgoing ( lock ) ; return ( error ) ; } } LIST_FOREACH ( overlap , & state -> ls_pending , lf_link ) { if ( ! lf_blocks ( lock , overlap ) ) continue ; error = lf_add_edge ( lock , overlap ) ; if ( error ) { lf_remove_outgoing ( lock ) ; return ( error ) ; } } return ( 0 ) ; }
Walk the list of locks for the file and create an out-going edge
 from lock to each blocking lock.
Walk the list of locks for the file and create an out - going edge from lock to each blocking lock .
/*
		 * We may assume that the active list is sorted by
		 * lf_start.
		 */ /*
		 * We've found a blocking lock. Add the corresponding
		 * edge to the graphs and see if it would cause a
		 * deadlock.
		 */ /*
		 * The only error that lf_add_edge returns is EDEADLK.
		 * Remove any edges we added and return the error.
		 */ /*
	 * We also need to add edges to sleeping locks that block
	 * us. This ensures that lf_wakeup_lock cannot grant two
	 * mutually blocking locks simultaneously and also enforces a
	 * 'first come, first served' fairness model. Note that this
	 * only happens if we are blocked by at least one active lock
	 * due to the call to lf_getblock in lf_setlock below.
	 */ /*
		 * We've found a blocking lock. Add the corresponding
		 * edge to the graphs and see if it would cause a
		 * deadlock.
		 */ /*
		 * The only error that lf_add_edge returns is EDEADLK.
		 * Remove any edges we added and return the error.
		 */