diff options
author | Vincent Bernat <bernat@luffy.cx> | 2014-01-11 20:55:42 +0100 |
---|---|---|
committer | Vincent Bernat <bernat@luffy.cx> | 2014-01-11 20:55:42 +0100 |
commit | f81b9d07098f631a2284f38e8b44478b087e5bf4 (patch) | |
tree | 9f00fa46139ef79006256d379964b6b932fe5917 | |
parent | cccbbaead99e3ad6a6ec975e046c62d9fb227e07 (diff) | |
download | libmemcached-f81b9d07098f631a2284f38e8b44478b087e5bf4.tar.gz |
Fix how current tps is computed.
With a low current TPS, the division will lead to a value of 0 TPS. We
multiply first, then divide to avoid this. This is a regression
introduced by fixing LP #613342. We also cast to uint64_t earlier.
-rw-r--r-- | clients/ms_conn.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clients/ms_conn.c b/clients/ms_conn.c index 2afc9fa1..0c2cf090 100644 --- a/clients/ms_conn.c +++ b/clients/ms_conn.c @@ -2473,7 +2473,7 @@ static bool ms_need_yield(ms_conn_t *c) { gettimeofday(&curr_time, NULL); time_diff= ms_time_diff(&ms_thread->startup_time, &curr_time); - tps= (int64_t)(((task->get_opt + task->set_opt) / (uint64_t)time_diff) * 1000000); + tps= (uint64_t)(task->get_opt + task->set_opt) * 1000000 / (uint64_t)time_diff; /* current throughput is greater than expected throughput */ if (tps > ms_thread->thread_ctx->tps_perconn) |