Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc8e8e8d authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

Test: Replace wait_until() with wait_for() am: 18f4d9eb

parents 40d92069 18f4d9eb
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -95,18 +95,10 @@ bool DnsMetricsListener::waitForNat64Prefix(ExpectNat64PrefixStatus status, mill

bool DnsMetricsListener::waitForPrivateDnsValidation(const std::string& serverAddr,
                                                     const bool validated) {
    const auto now = std::chrono::steady_clock::now();

    std::unique_lock lock(mMutex);
    ScopedLockAssertion assume_lock(mMutex);

    // onPrivateDnsValidationEvent() might already be invoked. Search for the record first.
    do {
        if (findAndRemoveValidationRecord({mNetId, serverAddr}, validated)) return true;
    } while (mCv.wait_until(lock, now + kEventTimeoutMs) != std::cv_status::timeout);

    // Timeout.
    return false;
    return mCv.wait_for(lock, kEventTimeoutMs, [&]() REQUIRES(mMutex) {
        return findAndRemoveValidationRecord({mNetId, serverAddr}, validated);
    });
}

bool DnsMetricsListener::findAndRemoveValidationRecord(const ServerKey& key, const bool value) {
+3 −11
Original line number Diff line number Diff line
@@ -68,18 +68,10 @@ constexpr milliseconds kRetryIntervalMs{20};

bool UnsolicitedEventListener::waitForPrivateDnsValidation(const std::string& serverAddr,
                                                           int validation, int protocol) {
    const auto now = std::chrono::steady_clock::now();

    std::unique_lock lock(mMutex);
    ScopedLockAssertion assume_lock(mMutex);

    // onPrivateDnsValidationEvent() might already be invoked. Search for the record first.
    do {
        if (findAndRemoveValidationRecord({mNetId, serverAddr, protocol}, validation)) return true;
    } while (mCv.wait_until(lock, now + kEventTimeoutMs) != std::cv_status::timeout);

    // Timeout.
    return false;
    return mCv.wait_for(lock, kEventTimeoutMs, [&]() REQUIRES(mMutex) {
        return findAndRemoveValidationRecord({mNetId, serverAddr, protocol}, validation);
    });
}

bool UnsolicitedEventListener::findAndRemoveValidationRecord(const ServerKey& key, int value) {