svn commit: r197452 - in stable/8/lib/libthr: . thread

Attilio Rao attilio at FreeBSD.org
Thu Sep 24 08:35:18 UTC 2009


Author: attilio
Date: Thu Sep 24 08:35:17 2009
New Revision: 197452
URL: http://svn.freebsd.org/changeset/base/197452

Log:
  MFC r197445:
  Let fall down in the hard path (thus handling shared waiters wakeup
  correctly) for the shared waiters also in the rwlock held in shared mode
  as well, fixing possible deadlocks.
  
  Please note that this is a special condition as we want this fix in
  before RC2 as we assume it is critical and so it has been handled
  as an instant-merge.  For the STABLE_7 branch, 1 week before the MFC
  is assumed.
  
  Approved by:	re (kib)

Modified:
  stable/8/lib/libthr/   (props changed)
  stable/8/lib/libthr/thread/thr_umtx.h

Modified: stable/8/lib/libthr/thread/thr_umtx.h
==============================================================================
--- stable/8/lib/libthr/thread/thr_umtx.h	Thu Sep 24 08:16:12 2009	(r197451)
+++ stable/8/lib/libthr/thread/thr_umtx.h	Thu Sep 24 08:35:17 2009	(r197452)
@@ -171,8 +171,11 @@ _thr_rwlock_unlock(struct urwlock *rwloc
 		for (;;) {
 			if (__predict_false(URWLOCK_READER_COUNT(state) == 0))
 				return (EPERM);
-			if (!((state & URWLOCK_WRITE_WAITERS) && URWLOCK_READER_COUNT(state) == 1)) {
-				if (atomic_cmpset_rel_32(&rwlock->rw_state, state, state-1))
+			if (!((state & (URWLOCK_WRITE_WAITERS |
+			    URWLOCK_READ_WAITERS)) &&
+			    URWLOCK_READER_COUNT(state) == 1)) {
+				if (atomic_cmpset_rel_32(&rwlock->rw_state,
+				    state, state-1))
 					return (0);
 				state = rwlock->rw_state;
 			} else {


More information about the svn-src-stable-8 mailing list