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);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to