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

Commit 23d7371b authored by Mike Yu's avatar Mike Yu
Browse files

Clean up expired DnsTlsDispatcher::Transport if DoT server list is empty

If we get no usable servers from getOrderedAndUsableServerList(),
we need to check and remove expired Transports; otherwise, we won't
be able to remove expired Transports if all the Transports are marked
as unusable.

Bug: 79727473
Test: atest
Change-Id: Ib04c0635e7e2a43bfd532d086d1f7acc8962392f
parent dff34e1b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -111,7 +111,13 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const std::list<DnsTlsServer>&
    const std::list<DnsTlsServer> servers(
            getOrderedAndUsableServerList(tlsServers, statp->netid, statp->mark));

    if (servers.empty()) LOG(WARNING) << "No usable DnsTlsServers";
    if (servers.empty()) {
        LOG(WARNING) << "No usable DnsTlsServers";

        // Call cleanup so the expired Transports can be removed as expected.
        std::lock_guard guard(sLock);
        cleanup(std::chrono::steady_clock::now());
    }

    DnsTlsTransport::Response code = DnsTlsTransport::Response::internal_error;
    int serverCount = 0;