Fix TSAN failue in env_test

Summary: Check for state of task before deleting it.

Test Plan: Run env_test with TSAN

Reviewers: igor, sdong

Reviewed By: sdong

Subscribers: meyering, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D35283
This commit is contained in:
Venkatesh Radhakrishnan 2015-03-18 11:40:46 -07:00
parent 155d468c56
commit 230e68727a

View File

@ -120,8 +120,15 @@ TEST_F(EnvPosixTest, UnSchedule) {
/* Schedule another task */
env_->Schedule(&SetBool, &called);
Env::Default()->SleepForMicroseconds(kDelayMicros);
for (int i = 0; i < kDelayMicros; i++) {
if (called.load(std::memory_order_relaxed)) {
break;
}
Env::Default()->SleepForMicroseconds(1);
}
ASSERT_TRUE(called.load(std::memory_order_relaxed));
ASSERT_TRUE(!sleeping_task.IsSleeping() && !sleeping_task1.IsSleeping());
}
TEST_F(EnvPosixTest, RunMany) {