]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
obj_bencher: protect with lock
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 03:55:37 +0000 (20:55 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:04 +0000 (13:18 -0700)
This makes coverity happy.

CID 716963: Data race condition (MISSING_LOCK)
At (1): Accessing "this->data.finished" ("bench_data.finished") requires the "Mutex._m" lock.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/obj_bencher.cc

index 81d01f103041aa715beda7d255a92793e20c5fa9..766edbed41902ce4627c63c24f31db7c4de244bc 100644 (file)
@@ -490,8 +490,6 @@ int ObjBencher::write_bench(int secondsToRun, int concurrentios) {
 }
 
 int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid) {
-  data.finished = 0;
-
   lock_cond lc(&lock);
   std::string name[concurrentios];
   std::string newName;
@@ -518,12 +516,14 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre
     contents[i] = new bufferlist();
   }
 
-  pthread_t print_thread;
-  pthread_create(&print_thread, NULL, status_printer, (void *)this);
-
   lock.Lock();
+  data.finished = 0;
   data.start_time = ceph_clock_now(g_ceph_context);
   lock.Unlock();
+
+  pthread_t print_thread;
+  pthread_create(&print_thread, NULL, status_printer, (void *)this);
+
   utime_t finish_time = data.start_time + time_to_run;
   //start initial reads
   for (int i = 0; i < concurrentios; ++i) {