FreeBSD/sys/nlm/nlm_prot_impl.c
/*
 * Cancel our async request - this must be called with
 * af->nh_host->nh_lock held. This is slightly complicated by a
 * potential race with our own callback. If we fail to cancel the
 * lock, it must already have been granted - we make sure our async
 * task has completed by calling taskqueue_drain in this case.
 */
Cancel our async request - this must be called with
af->nh_host->nh_lock held. This is slightly complicated by a
potential race with our own callback. If we fail to cancel the
lock, it must already have been granted - we make sure our async
task has completed by calling taskqueue_drain in this case.
Cancel our async request - this must be called with af - > nh_host - > nh_lock held . This is slightly complicated by a potential race with our own callback . If we fail to cancel the lock it must already have been granted - we make sure our async task has completed by calling taskqueue_drain in this case .
static int
nlm_cancel_async_lock(struct nlm_async_lock *af)
{
	struct nlm_host *host = af->af_host;
	int error;
	mtx_assert(&host->nh_lock, MA_OWNED);
	mtx_unlock(&host->nh_lock);
	error = VOP_ADVLOCKASYNC(af->af_vp, NULL, F_CANCEL, &af->af_fl,
	    F_REMOTE, NULL, &af->af_cookie);
	if (error) {
		taskqueue_drain(taskqueue_thread, &af->af_task);
	}
	mtx_lock(&host->nh_lock);
	if (!error) {
		NLM_DEBUG(2, "NLM: async lock %p for %s (sysid %d) "
		    "cancelled\n", af, host->nh_caller_name, host->nh_sysid);
		TAILQ_REMOVE(&host->nh_pending, af, af_link);
		mtx_unlock(&host->nh_lock);
		nlm_free_async_lock(af);
		mtx_lock(&host->nh_lock);
	}
	return (error);
}
static int nlm_cancel_async_lock ( struct nlm_async_lock * af ) { struct nlm_host * host = af -> af_host ; int error ; mtx_assert ( & host -> nh_lock , MA_OWNED ) ; mtx_unlock ( & host -> nh_lock ) ; error = VOP_ADVLOCKASYNC ( af -> af_vp , NULL , F_CANCEL , & af -> af_fl , F_REMOTE , NULL , & af -> af_cookie ) ; if ( error ) { taskqueue_drain ( taskqueue_thread , & af -> af_task ) ; } mtx_lock ( & host -> nh_lock ) ; if ( ! error ) { NLM_DEBUG ( 2 , " " " \n " , af , host -> nh_caller_name , host -> nh_sysid ) ; TAILQ_REMOVE ( & host -> nh_pending , af , af_link ) ; mtx_unlock ( & host -> nh_lock ) ; nlm_free_async_lock ( af ) ; mtx_lock ( & host -> nh_lock ) ; } return ( error ) ; }
Cancel our async request - this must be called with
 af->nh_host->nh_lock held.
Cancel our async request - this must be called with af - > nh_host - > nh_lock held .
/*
		 * We failed to cancel - make sure our callback has
		 * completed before we continue.
		 */ /*
		 * Remove from the nh_pending list and free now that
		 * we are safe from the callback.
		 */