summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lockf.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-24 03:57:44 +0000
committerjhb <jhb@FreeBSD.org>2001-03-24 03:57:44 +0000
commit0b6ef06d5c7b29b3c35420534ee9a39c6ece09ee (patch)
treefb6bccea154bdb16b498f0d239f1f8b993753e67 /sys/kern/kern_lockf.c
parent2144cdef03cafb0c894fa5c1d9de509e77f42933 (diff)
downloadFreeBSD-src-0b6ef06d5c7b29b3c35420534ee9a39c6ece09ee.zip
FreeBSD-src-0b6ef06d5c7b29b3c35420534ee9a39c6ece09ee.tar.gz
Protect p_wmesg and p_wchan with sched_lock while checking for deadlocks
with other byte range file locks.
Diffstat (limited to 'sys/kern/kern_lockf.c')
-rw-r--r--sys/kern/kern_lockf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index 86855ea..6c96c9c 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -234,6 +234,7 @@ lf_setlock(lock)
/* The block is waiting on something */
wproc = (struct proc *)block->lf_id;
+ mtx_lock_spin(&sched_lock);
while (wproc->p_wchan &&
(wproc->p_wmesg == lockstr) &&
(i++ < maxlockdepth)) {
@@ -244,10 +245,12 @@ lf_setlock(lock)
break;
wproc = (struct proc *)waitblock->lf_id;
if (wproc == (struct proc *)lock->lf_id) {
+ mtx_unlock_spin(&sched_lock);
free(lock, M_LOCKF);
return (EDEADLK);
}
}
+ mtx_unlock_spin(&sched_lock);
}
/*
* For flock type locks, we must first remove
OpenPOWER on IntegriCloud