svn commit: r255788 - head/sys/kern
Davide Italiano
davide at FreeBSD.org
Sun Sep 22 14:09:08 UTC 2013
Author: davide
Date: Sun Sep 22 14:09:07 2013
New Revision: 255788
URL: http://svnweb.freebsd.org/changeset/base/255788
Log:
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)
Modified:
head/sys/kern/kern_rwlock.c
head/sys/kern/kern_sx.c
Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c Sun Sep 22 13:54:08 2013 (r255787)
+++ head/sys/kern/kern_rwlock.c Sun Sep 22 14:09:07 2013 (r255788)
@@ -147,9 +147,9 @@ lock_rw(struct lock_object *lock, uintpt
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);
}
}
Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c Sun Sep 22 13:54:08 2013 (r255787)
+++ head/sys/kern/kern_sx.c Sun Sep 22 14:09:07 2013 (r255788)
@@ -162,9 +162,9 @@ lock_sx(struct lock_object *lock, uintpt
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);
}
}
More information about the svn-src-all
mailing list