From a6b90f1942fa0f6e29cd0fcb99c84ffb91a47599 Mon Sep 17 00:00:00 2001 From: Zardosht Kasheff Date: Wed, 17 Apr 2013 00:00:09 -0400 Subject: [PATCH] [t:4288], fix performance issue in unlock_worker_op in stress tests git-svn-id: file:///svn/toku/tokudb@39608 c7de825b-a66e-492c-adef-691d508d4ae1 --- src/tests/threaded_stress_test_helpers.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tests/threaded_stress_test_helpers.h b/src/tests/threaded_stress_test_helpers.h index 03d5255e5f4..dde5a1a4b63 100644 --- a/src/tests/threaded_stress_test_helpers.h +++ b/src/tests/threaded_stress_test_helpers.h @@ -121,15 +121,17 @@ static void lock_worker_op(struct worker_extra* we) { static void unlock_worker_op(struct worker_extra* we) { ARG arg = we->thread_arg; - toku_pthread_mutex_lock(we->operation_lock_mutex); - if (arg->lock_type == STRESS_LOCK_SHARED) { - rwlock_read_unlock(we->operation_lock); - } else if (arg->lock_type == STRESS_LOCK_EXCL) { - rwlock_write_unlock(we->operation_lock); - } else { - assert(arg->lock_type == STRESS_LOCK_NONE); + if (arg->lock_type != STRESS_LOCK_NONE) { + toku_pthread_mutex_lock(we->operation_lock_mutex); + if (arg->lock_type == STRESS_LOCK_SHARED) { + rwlock_read_unlock(we->operation_lock); + } else if (arg->lock_type == STRESS_LOCK_EXCL) { + rwlock_write_unlock(we->operation_lock); + } else { + assert(false); + } + toku_pthread_mutex_unlock(we->operation_lock_mutex); } - toku_pthread_mutex_unlock(we->operation_lock_mutex); } static void *worker(void *arg_v) {