Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Sep 2013 14:09:07 +0000 (UTC)
From:      Davide Italiano <davide@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255788 - head/sys/kern
Message-ID:  <201309221409.r8ME97Gr051958@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309221409.r8ME97Gr051958>