diff --git a/db/db_test.cc b/db/db_test.cc index 42f4bf0cb..e28a27914 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -93,10 +93,11 @@ class AtomicCounter { uint64_t start = env_->NowMicros(); while (count_ < count) { uint64_t now = env_->NowMicros(); - cond_count_.TimedWait(now + /*1s*/ 1 * 000 * 000); - if (env_->NowMicros() - start > /*10s*/ 10 * 000 * 000) { + const uint64_t elapsed_micros = (now > start) ? now - start : 0; + if (elapsed_micros > /*10s*/ 10 * 000 * 000) { return false; } + cond_count_.TimedWait(now + /*1s*/ 1 * 000 * 000); if (count_ < count) { GTEST_LOG_(WARNING) << "WaitFor is taking more time than usual"; }