Commit fad8c200 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1640 Bugfixes in rwlock (windows) implementation.

git-svn-id: file:///svn/toku/tokudb@11338 c7de825b-a66e-492c-adef-691d508d4ae1
parent 91fd4931
...@@ -30,32 +30,48 @@ toku_pthread_rwlock_destroy(toku_pthread_rwlock_t *rwlock) { ...@@ -30,32 +30,48 @@ toku_pthread_rwlock_destroy(toku_pthread_rwlock_t *rwlock) {
int int
toku_pthread_rwlock_rdlock(toku_pthread_rwlock_t *rwlock) { toku_pthread_rwlock_rdlock(toku_pthread_rwlock_t *rwlock) {
assert(rwlock->initialized); assert(rwlock->initialized);
int r = toku_pthread_mutex_lock(&rwlock->mutex); int r;
if (r==0) rwlock_read_lock(&rwlock->rwlock, &rwlock->mutex); r = toku_pthread_mutex_lock(&rwlock->mutex);
assert(r==0);
rwlock_read_lock(&rwlock->rwlock, &rwlock->mutex);
r = toku_pthread_mutex_unlock(&rwlock->mutex);
assert(r==0);
return r; return r;
} }
int int
toku_pthread_rwlock_rdunlock(toku_pthread_rwlock_t *rwlock) { toku_pthread_rwlock_rdunlock(toku_pthread_rwlock_t *rwlock) {
assert(rwlock->initialized); assert(rwlock->initialized);
int r = toku_pthread_mutex_lock(&rwlock->mutex); int r;
if (r==0) rwlock_read_unlock(&rwlock->rwlock); r = toku_pthread_mutex_lock(&rwlock->mutex);
assert(r==0);
rwlock_read_unlock(&rwlock->rwlock);
r = toku_pthread_mutex_unlock(&rwlock->mutex);
assert(r==0);
return r; return r;
} }
int int
toku_pthread_rwlock_wrlock(toku_pthread_rwlock_t *rwlock) { toku_pthread_rwlock_wrlock(toku_pthread_rwlock_t *rwlock) {
assert(rwlock->initialized); assert(rwlock->initialized);
int r = toku_pthread_mutex_lock(&rwlock->mutex); int r;
if (r==0) rwlock_write_lock(&rwlock->rwlock, &rwlock->mutex); r = toku_pthread_mutex_lock(&rwlock->mutex);
assert(r==0);
rwlock_write_lock(&rwlock->rwlock, &rwlock->mutex);
r = toku_pthread_mutex_unlock(&rwlock->mutex);
assert(r==0);
return r; return r;
} }
int int
toku_pthread_rwlock_wrunlock(toku_pthread_rwlock_t *rwlock) { toku_pthread_rwlock_wrunlock(toku_pthread_rwlock_t *rwlock) {
assert(rwlock->initialized); assert(rwlock->initialized);
int r = toku_pthread_mutex_unlock(&rwlock->mutex); int r;
if (r==0) rwlock_write_unlock(&rwlock->rwlock); r = toku_pthread_mutex_lock(&rwlock->mutex);
assert(r==0);
rwlock_write_unlock(&rwlock->rwlock);
r = toku_pthread_mutex_unlock(&rwlock->mutex);
assert(r==0);
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment