svn commit: r309783 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Sat Dec 10 02:56:45 UTC 2016
Author: markj
Date: Sat Dec 10 02:56:44 2016
New Revision: 309783
URL: https://svnweb.freebsd.org/changeset/base/309783
Log:
Return a non-NULL owner only if the lock is exclusively held in owner_sx().
Fix some whitespace bugs while here.
MFC after: 2 weeks
Modified:
head/sys/kern/kern_sx.c
Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c Sat Dec 10 01:40:10 2016 (r309782)
+++ head/sys/kern/kern_sx.c Sat Dec 10 02:56:44 2016 (r309783)
@@ -215,12 +215,14 @@ unlock_sx(struct lock_object *lock)
int
owner_sx(const struct lock_object *lock, struct thread **owner)
{
- const struct sx *sx = (const struct sx *)lock;
- uintptr_t x = sx->sx_lock;
+ const struct sx *sx;
+ uintptr_t x;
- *owner = (struct thread *)SX_OWNER(x);
- return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) :
- (*owner != NULL));
+ sx = (const struct sx *)lock;
+ x = sx->sx_lock;
+ *owner = NULL;
+ return ((x & SX_LOCK_SHARED) != 0 ? (SX_SHARERS(x) != 0) :
+ ((*owner = (struct thread *)SX_OWNER(x)) != NULL));
}
#endif
More information about the svn-src-head
mailing list