]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fixed the valgrind error in ColumnFamilyTest::CreateAndDropRace
authorYueh-Hsuan Chiang <yhchiang@fb.com>
Thu, 10 Dec 2015 19:53:53 +0000 (11:53 -0800)
committerYueh-Hsuan Chiang <yhchiang@fb.com>
Thu, 10 Dec 2015 19:53:53 +0000 (11:53 -0800)
Summary: Fixed the valgrind error in ColumnFamilyTest::CreateAndDropRace

Test Plan: valgrind --error-exitcode=2 --leak-check=full ./column_family_test

Reviewers: kradhakrishnan, rven, anthony, IslamAbdelRahman, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D51795

db/column_family_test.cc

index cf77d6d240ad4298ed433ec05afdb7b5c13e6441..b877ea8a1b3850d0555050acf7cd1ab8eb644f07 100644 (file)
@@ -1270,13 +1270,15 @@ const int kMainThreadStartPersistingOptionsFile = 1;
 const int kChildThreadFinishDroppingColumnFamily = 2;
 const int kChildThreadWaitingMainThreadPersistOptions = 3;
 void DropSingleColumnFamily(ColumnFamilyTest* cf_test, int cf_id,
-                            std::vector<Comparator*> comparators) {
+                            std::vector<Comparator*>* comparators) {
   while (test_stage < kMainThreadStartPersistingOptionsFile) {
     Env::Default()->SleepForMicroseconds(100);
   }
   cf_test->DropColumnFamilies({cf_id});
-  delete comparators[cf_id];
-  comparators[cf_id] = nullptr;
+  if ((*comparators)[cf_id]) {
+    delete (*comparators)[cf_id];
+    (*comparators)[cf_id] = nullptr;
+  }
   test_stage = kChildThreadFinishDroppingColumnFamily;
 }
 }  // namespace
@@ -1328,15 +1330,19 @@ TEST_F(ColumnFamilyTest, CreateAndDropRace) {
 
   // Start a thread that will drop the first column family
   // and its comparator
-  std::thread drop_cf_thread(DropSingleColumnFamily, this, 1, comparators);
+  std::thread drop_cf_thread(DropSingleColumnFamily, this, 1, &comparators);
 
   DropColumnFamilies({2});
 
   drop_cf_thread.join();
-
   Close();
   Destroy();
   rocksdb::SyncPoint::GetInstance()->DisableProcessing();
+  for (auto* comparator : comparators) {
+    if (comparator) {
+      delete comparator;
+    }
+  }
 }
 #endif  // !ROCKSDB_LITE