diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-10-20 02:34:02 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-10-20 02:34:02 +0000 |
commit | 1126acd0dc63c0b7713bc81b5e71684fb87c7fc0 (patch) | |
tree | 6187f2f58cdd428ad27ac0f3fb042a22046585f2 /lib/libthr/thread/thr_rwlock.c | |
parent | 520d21ea78ad909c12b58c25403192af742c855c (diff) | |
download | FreeBSD-src-1126acd0dc63c0b7713bc81b5e71684fb87c7fc0.zip FreeBSD-src-1126acd0dc63c0b7713bc81b5e71684fb87c7fc0.tar.gz |
Revert revision 214007, I realized that MySQL wants to resolve
a silly rwlock deadlock problem, the deadlock is caused by writer
waiters, if a thread has already locked a reader lock, and wants to
acquire another reader lock, it will be blocked by writer waiters,
but we had already fixed it years ago.
Diffstat (limited to 'lib/libthr/thread/thr_rwlock.c')
-rw-r--r-- | lib/libthr/thread/thr_rwlock.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c index 20b9b79..ebdeae7 100644 --- a/lib/libthr/thread/thr_rwlock.c +++ b/lib/libthr/thread/thr_rwlock.c @@ -63,19 +63,13 @@ __weak_reference(_pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock); */ static int -rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr __unused) { pthread_rwlock_t prwlock; prwlock = (pthread_rwlock_t)calloc(1, sizeof(struct pthread_rwlock)); if (prwlock == NULL) return (ENOMEM); - if (attr != NULL) - prwlock->kind = (*attr)->kind; - else - prwlock->kind = PTHREAD_RWLOCK_DEFAULT_NP; - if (prwlock->kind == PTHREAD_RWLOCK_PREFER_READER_NP) - prwlock->lock.rw_flags |= URWLOCK_PREFER_READER; *rwlock = prwlock; return (0); } @@ -118,7 +112,7 @@ init_static(struct pthread *thread, pthread_rwlock_t *rwlock) } int -_pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +_pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { *rwlock = NULL; return (rwlock_init(rwlock, attr)); @@ -266,14 +260,6 @@ rwlock_wrlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime) CHECK_AND_INIT_RWLOCK - if (__predict_false(prwlock->owner == curthread)) { - if (__predict_false( - prwlock->kind == PTHREAD_RWLOCK_PREFER_WRITER_NP)) { - prwlock->recurse++; - return (0); - } - } - /* * POSIX said the validity of the abstimeout parameter need * not be checked if the lock can be immediately acquired. @@ -349,13 +335,6 @@ _pthread_rwlock_unlock (pthread_rwlock_t *rwlock) if (state & URWLOCK_WRITE_OWNER) { if (__predict_false(prwlock->owner != curthread)) return (EPERM); - if (__predict_false( - prwlock->kind == PTHREAD_RWLOCK_PREFER_WRITER_NP)) { - if (prwlock->recurse > 0) { - prwlock->recurse--; - return (0); - } - } prwlock->owner = NULL; } |