From 4e7d6d87ca54ea36b70380b6a5d7adccefb42c7d Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 22 Jan 2017 11:17:44 +0300 Subject: [PATCH] Move tx_rate check from thread_run() to sb_event_stop(). This is required for tx_rate to also work with Lua scripts. --- sysbench/sysbench.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index f62b0b7..d27fc30 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -521,6 +521,13 @@ void sb_event_stop(int thread_id) sb_histogram_update(&sb_latency_histogram, NS2MS(value)); db_thread_stat_inc(thread_id, DB_STAT_TRX); + + if (sb_globals.tx_rate > 0) + { + pthread_mutex_lock(&event_queue_mutex); + sb_globals.concurrency--; + pthread_mutex_unlock(&event_queue_mutex); + } } @@ -543,13 +550,6 @@ static int thread_run(sb_test_t *test, int thread_id) rc = test->ops.execute_event(&event, thread_id); sb_event_stop(thread_id); - - if (sb_globals.tx_rate > 0) - { - pthread_mutex_lock(&event_queue_mutex); - sb_globals.concurrency--; - pthread_mutex_unlock(&event_queue_mutex); - } } return rc;