]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common:bench test bug when <seconds>=0 16382/head
authorPC <pc@localhost.localdomain>
Thu, 13 Jul 2017 05:38:46 +0000 (13:38 +0800)
committerPCzhangPC <pengcheng.zhang@easystack.cn>
Tue, 8 Aug 2017 05:27:28 +0000 (13:27 +0800)
Fixes:
src/common/obj_bencher.cc b/src/common/obj_bencher.cc :write_bench(),seq_read_bench(),rand_read_bench()
the program may fall into a dead loop if the <seconds> set as 0

Signed-off-by:PCzhangPC pengcheng.zhang@easystack.cn

src/common/obj_bencher.cc

index 4eaeba3471f7c5c4bef0b343796f5de0cf34d8b6..411dac3dd9d6a2637e38eab0cc320cc1c054bfcd 100644 (file)
@@ -460,7 +460,7 @@ int ObjBencher::write_bench(int secondsToRun,
   stopTime = data.start_time + runtime;
   slot = 0;
   lock.Lock();
-  while (!secondsToRun || ceph_clock_now() < stopTime) {
+  while (secondsToRun && ceph_clock_now() < stopTime) {
     bool found = false;
     while (1) {
       int old_slot = slot;
@@ -690,7 +690,7 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
   bufferlist *cur_contents;
 
   slot = 0;
-  while ((!seconds_to_run || ceph_clock_now() < finish_time) &&
+  while ((seconds_to_run && ceph_clock_now() < finish_time) &&
         num_objects > data.started) {
     lock.Lock();
     int old_slot = slot;
@@ -920,7 +920,7 @@ int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurr
   int rand_id;
 
   slot = 0;
-  while ((!seconds_to_run || ceph_clock_now() < finish_time)) {
+  while ((seconds_to_run && ceph_clock_now() < finish_time)) {
     lock.Lock();
     int old_slot = slot;
     bool found = false;