FreeBSD/sys/kern/kern_lockf.c
/*
 * Cancel a pending lock request, either as a result of a signal or a
 * cancel request for an async lock.
 */
Cancel a pending lock request, either as a result of a signal or a
cancel request for an async lock.
Cancel a pending lock request either as a result of a signal or a cancel request for an async lock .
static void
lf_cancel_lock(struct lockf *state, struct lockf_entry *lock)
{
	struct lockf_entry_list granted;
	LIST_REMOVE(lock, lf_link);
	sx_xlock(&lf_owner_graph_lock);
	lf_remove_outgoing(lock);
	sx_xunlock(&lf_owner_graph_lock);
	LIST_INIT(&granted);
	lf_update_dependancies(state, lock, TRUE, &granted);
	lf_free_lock(lock);
	while (!LIST_EMPTY(&granted)) {
		lock = LIST_FIRST(&granted);
		LIST_REMOVE(lock, lf_link);
		lf_activate_lock(state, lock);
	}
}
static void lf_cancel_lock ( struct lockf * state , struct lockf_entry * lock ) { struct lockf_entry_list granted ; LIST_REMOVE ( lock , lf_link ) ; sx_xlock ( & lf_owner_graph_lock ) ; lf_remove_outgoing ( lock ) ; sx_xunlock ( & lf_owner_graph_lock ) ; LIST_INIT ( & granted ) ; lf_update_dependancies ( state , lock , TRUE , & granted ) ; lf_free_lock ( lock ) ; while ( ! LIST_EMPTY ( & granted ) ) { lock = LIST_FIRST ( & granted ) ; LIST_REMOVE ( lock , lf_link ) ; lf_activate_lock ( state , lock ) ; } }
Cancel a pending lock request, either as a result of a signal or a
 cancel request for an async lock.
Cancel a pending lock request either as a result of a signal or a cancel request for an async lock .
/*
	 * Note it is theoretically possible that cancelling this lock
	 * may allow some other pending lock to become
	 * active. Consider this case:
	 *
	 * Owner	Action		Result		Dependencies
	 * 
	 * A:		lock [0..0]	succeeds	
	 * B:		lock [2..2]	succeeds	
	 * C:		lock [1..2]	blocked		C->B
	 * D:		lock [0..1]	blocked		C->B,D->A,D->C
	 * A:		unlock [0..0]			C->B,D->C
	 * C:		cancel [1..2]	
	 */ /*
	 * Removing out-going edges is simple.
	 */ /*
	 * Removing in-coming edges may allow some other lock to
	 * become active - we use lf_update_dependancies to figure
	 * this out.
	 */ /*
	 * Feed any newly active locks to lf_activate_lock.
	 */