提交 f0a8e5a2 编写于 作者: Y Yueh-Hsuan Chiang

Fixed the valgrind error in ColumnFamilyTest::CreateAndDropRace

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
上级 9e446290
...@@ -1270,13 +1270,15 @@ const int kMainThreadStartPersistingOptionsFile = 1; ...@@ -1270,13 +1270,15 @@ const int kMainThreadStartPersistingOptionsFile = 1;
const int kChildThreadFinishDroppingColumnFamily = 2; const int kChildThreadFinishDroppingColumnFamily = 2;
const int kChildThreadWaitingMainThreadPersistOptions = 3; const int kChildThreadWaitingMainThreadPersistOptions = 3;
void DropSingleColumnFamily(ColumnFamilyTest* cf_test, int cf_id, void DropSingleColumnFamily(ColumnFamilyTest* cf_test, int cf_id,
std::vector<Comparator*> comparators) { std::vector<Comparator*>* comparators) {
while (test_stage < kMainThreadStartPersistingOptionsFile) { while (test_stage < kMainThreadStartPersistingOptionsFile) {
Env::Default()->SleepForMicroseconds(100); Env::Default()->SleepForMicroseconds(100);
} }
cf_test->DropColumnFamilies({cf_id}); cf_test->DropColumnFamilies({cf_id});
delete comparators[cf_id]; if ((*comparators)[cf_id]) {
comparators[cf_id] = nullptr; delete (*comparators)[cf_id];
(*comparators)[cf_id] = nullptr;
}
test_stage = kChildThreadFinishDroppingColumnFamily; test_stage = kChildThreadFinishDroppingColumnFamily;
} }
} // namespace } // namespace
...@@ -1328,15 +1330,19 @@ TEST_F(ColumnFamilyTest, CreateAndDropRace) { ...@@ -1328,15 +1330,19 @@ TEST_F(ColumnFamilyTest, CreateAndDropRace) {
// Start a thread that will drop the first column family // Start a thread that will drop the first column family
// and its comparator // and its comparator
std::thread drop_cf_thread(DropSingleColumnFamily, this, 1, comparators); std::thread drop_cf_thread(DropSingleColumnFamily, this, 1, &comparators);
DropColumnFamilies({2}); DropColumnFamilies({2});
drop_cf_thread.join(); drop_cf_thread.join();
Close(); Close();
Destroy(); Destroy();
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
for (auto* comparator : comparators) {
if (comparator) {
delete comparator;
}
}
} }
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册