freebsd_network: Implement mtx_destroy for spinlocks.

Somehow, I missed this when implementing MTX_SPIN in the first place,
and it went largely unnoticed because MTX_SPIN is rarely used and
apparently even more rarely destroyed.

Should fix #15749.
This commit is contained in:
waddlesplash 2020-03-24 21:06:37 -04:00
parent cb837539f5
commit 8e12c92fee

View File

@ -10,8 +10,6 @@
#include <compat/sys/mutex.h>
// these methods are bit unfriendly, a bit too much panic() around
struct mtx Giant;
struct rw_lock ifnet_rwlock;
struct mtx gIdStoreLock;
@ -49,10 +47,13 @@ mtx_sysinit(void *arg)
void
mtx_destroy(struct mtx *mutex)
{
if ((mutex->type & MTX_RECURSE) != 0)
if ((mutex->type & MTX_RECURSE) != 0) {
recursive_lock_destroy(&mutex->u.recursive);
else
} else if ((mutex->type & MTX_SPIN) != 0) {
KASSERT(!B_SPINLOCK_IS_LOCKED(&mutex->u.spinlock.lock), ("spin mutex is locked"));
} else {
mutex_destroy(&mutex->u.mutex.lock);
}
}