Do the lock order check skip for the LOP_TRYLOCK case after the check for

recursing on a lock instead of before.  This fixes a bug where WITNESS
could get a little confused if you did an sx_tryslock() on a sx lock that
you already had an slock on.  WITNESS would still function correctly but
it could result in weirdness in the output of 'show locks'.  This also
makes it possible for mtx_trylock() to recurse on a lock.
This commit is contained in:
John Baldwin 2003-03-11 20:54:37 +00:00
parent ecdf4409f9
commit d278a7f9ba

View File

@ -555,14 +555,6 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
} else
lock_list = PCPU_PTR(spinlocks);
/*
* Try locks do not block if they fail to acquire the lock, thus
* there is no danger of deadlocks or of switching while holding a
* spin lock if we acquire a lock via a try operation.
*/
if (flags & LOP_TRYLOCK)
goto out;
/*
* Is this the first lock acquired? If so, then no order checking
* is needed.
@ -608,6 +600,14 @@ witness_lock(struct lock_object *lock, int flags, const char *file, int line)
return;
}
/*
* Try locks do not block if they fail to acquire the lock, thus
* there is no danger of deadlocks or of switching while holding a
* spin lock if we acquire a lock via a try operation.
*/
if (flags & LOP_TRYLOCK)
goto out;
/*
* Check for duplicate locks of the same type. Note that we only
* have to check for this on the last lock we just acquired. Any