This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Consistently use the same value to indicate exclusively-held and

shared-held locks for all the primitives in lc_lock/lc_unlock routines.
This fixes the problems introduced in r255747, which indeed introduced an
inversion in the logic.

Reported by:	many
Tested by:	bdrewery, pho, lme, Adam McDougall, O. Hartmann
Approved by:	re (glebius)
  • Loading branch information...
dcci committed Sep 22, 2013
1 parent 12fb397 commit 30f0365ae9f2024c5ae68ffcb5370d12d1facc13
Showing with 8 additions and 8 deletions.
  1. +4 −4 sys/kern/kern_rwlock.c
  2. +4 −4 sys/kern/kern_sx.c
View
@@ -147,9 +147,9 @@ lock_rw(struct lock_object *lock, uintptr_t how)
rw = (struct rwlock *)lock;
if (how)
- rw_wlock(rw);
- else
rw_rlock(rw);
+ else
+ rw_wlock(rw);
}
uintptr_t
@@ -161,10 +161,10 @@ unlock_rw(struct lock_object *lock)
rw_assert(rw, RA_LOCKED | LA_NOTRECURSED);
if (rw->rw_lock & RW_LOCK_READ) {
rw_runlock(rw);
- return (0);
+ return (1);
} else {
rw_wunlock(rw);
- return (1);
+ return (0);
}
}
View
@@ -162,9 +162,9 @@ lock_sx(struct lock_object *lock, uintptr_t how)
sx = (struct sx *)lock;
if (how)
- sx_xlock(sx);
- else
sx_slock(sx);
+ else
+ sx_xlock(sx);
}
uintptr_t
@@ -176,10 +176,10 @@ unlock_sx(struct lock_object *lock)
sx_assert(sx, SA_LOCKED | SA_NOTRECURSED);
if (sx_xlocked(sx)) {
sx_xunlock(sx);
- return (1);
+ return (0);
} else {
sx_sunlock(sx);
- return (0);
+ return (1);
}
}

0 comments on commit 30f0365

Please sign in to comment.