PERFORCE change 143881 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Jun 21 14:47:32 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143881
Change 143881 by hselasky at hselasky_laptop001 on 2008/06/21 14:47:07
Fix a problem with Giant and condition variables.
Please see the diff for an explanation.
Maybe someone into locking can review this patch?
Affected files ...
.. //depot/projects/usb/src/sys/kern/kern_mutex.c#9 edit
Differences ...
==== //depot/projects/usb/src/sys/kern/kern_mutex.c#9 (text+ko) ====
@@ -133,7 +133,8 @@
void
lock_mtx(struct lock_object *lock, int how)
{
-
+ if (how == 1)
+ return;
mtx_lock((struct mtx *)lock);
}
@@ -150,6 +151,18 @@
struct mtx *m;
m = (struct mtx *)lock;
+ if ((m == &Giant) && (!mtx_owned(m))) {
+ /*
+ * Sometimes DROP_GIANT() gets in our way when we use
+ * the system condition variables passing the "Giant"
+ * mutex. If Giant is not locked when we get into this
+ * function then we can simply ignore those cases,
+ * because the locking is then handled by the DROP_XXX
+ * macros!
+ */
+ return (1);
+ }
+
mtx_assert(m, MA_OWNED | MA_NOTRECURSED);
mtx_unlock(m);
return (0);
More information about the p4-projects
mailing list