Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Sep 2009 08:41:14 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r196913 - stable/7/lib/libthr/thread
Message-ID:  <200909070841.n878fE6M008345@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Mon Sep  7 08:41:14 2009
New Revision: 196913
URL: http://svn.freebsd.org/changeset/base/196913

Log:
  MFC r195403:
  Fix a bug in read lock acquisition for rwlocks by bumping rdlock_count
  when a successfull rwlock_rdlock_common() take place.

Modified:
  stable/7/lib/libthr/thread/thr_rtld.c
  stable/7/lib/libthr/thread/thr_rwlock.c

Modified: stable/7/lib/libthr/thread/thr_rtld.c
==============================================================================
--- stable/7/lib/libthr/thread/thr_rtld.c	Mon Sep  7 08:37:25 2009	(r196912)
+++ stable/7/lib/libthr/thread/thr_rtld.c	Mon Sep  7 08:41:14 2009	(r196913)
@@ -116,6 +116,7 @@ _thr_rtld_rlock_acquire(void *lock)
 	THR_CRITICAL_ENTER(curthread);
 	while (_thr_rwlock_rdlock(&l->lock, 0, NULL) != 0)
 		;
+	curthread->rdlock_count++;
 	RESTORE_ERRNO();
 }
 
@@ -150,6 +151,7 @@ _thr_rtld_lock_release(void *lock)
 	
 	state = l->lock.rw_state;
 	if (_thr_rwlock_unlock(&l->lock) == 0) {
+		curthread->rdlock_count--;
 		if ((state & URWLOCK_WRITE_OWNER) == 0) {
 			THR_CRITICAL_LEAVE(curthread);
 		} else {

Modified: stable/7/lib/libthr/thread/thr_rwlock.c
==============================================================================
--- stable/7/lib/libthr/thread/thr_rwlock.c	Mon Sep  7 08:37:25 2009	(r196912)
+++ stable/7/lib/libthr/thread/thr_rwlock.c	Mon Sep  7 08:41:14 2009	(r196913)
@@ -177,10 +177,11 @@ rwlock_rdlock_common(pthread_rwlock_t *r
 		/* if interrupted, try to lock it in userland again. */
 		if (_thr_rwlock_tryrdlock(&prwlock->lock, flags) == 0) {
 			ret = 0;
-			curthread->rdlock_count++;
 			break;
 		}
 	}
+	if (ret == 0)
+		curthread->rdlock_count++;
 	return (ret);
 }
 



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