Loading DnsTlsDispatcher.cpp +3 −23 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ #include "resolv_cache.h" #include "resolv_private.h" #include "stats.pb.h" #include "util.h" #include <android-base/logging.h> Loading Loading @@ -244,7 +243,7 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const DnsTlsServer& server, un void DnsTlsDispatcher::forceCleanup(unsigned netId) { std::lock_guard guard(sLock); cleanup(std::chrono::steady_clock::now(), std::chrono::seconds(-1), netId); cleanup(std::chrono::steady_clock::now(), netId); } DnsTlsTransport::Result DnsTlsDispatcher::queryInternal(Transport& xport, Loading Loading @@ -277,41 +276,22 @@ DnsTlsTransport::Result DnsTlsDispatcher::queryInternal(Transport& xport, // This timeout effectively controls how long to keep SSL session tickets. static constexpr std::chrono::minutes IDLE_TIMEOUT(5); void DnsTlsDispatcher::maybeCleanup(std::chrono::time_point<std::chrono::steady_clock> now) { // Make the timeout tunable via experiment flag for testing. std::chrono::seconds unusable_xport_idle_timeout{-1}; const int value = Experiments::getInstance()->getFlag("dot_keep_unusable_xport_sec", -1); if (value > -1 && isUserDebugBuild() && std::chrono::seconds(value) < IDLE_TIMEOUT) { unusable_xport_idle_timeout = std::chrono::seconds(value); } // To avoid scanning mStore after every query, return early if a cleanup has been // performed recently. const std::chrono::seconds timeout = (unusable_xport_idle_timeout < IDLE_TIMEOUT) ? unusable_xport_idle_timeout : IDLE_TIMEOUT; if (now - mLastCleanup < timeout) { if (now - mLastCleanup < IDLE_TIMEOUT) { return; } cleanup(now, unusable_xport_idle_timeout, std::nullopt); cleanup(now, std::nullopt); mLastCleanup = now; } void DnsTlsDispatcher::cleanup(std::chrono::time_point<std::chrono::steady_clock> now, std::chrono::seconds unusable_xport_idle_timeout, std::optional<unsigned> netId) { std::erase_if(mStore, [&](const auto& item) REQUIRES(sLock) { auto const& [_, xport] = item; if (xport->useCount == 0) { // Remove the Transports of the associated network. if (netId.has_value() && xport->mNetId == netId.value()) return true; // Remove all expired Transports. if (now - xport->lastUsed > IDLE_TIMEOUT) return true; // Unusable Transports should be removed earlier. if (!xport->usable() && unusable_xport_idle_timeout.count() >= 0 && now - xport->lastUsed > unusable_xport_idle_timeout) return true; } return false; }); Loading DnsTlsDispatcher.h +1 −2 Original line number Diff line number Diff line Loading @@ -165,8 +165,7 @@ class DnsTlsDispatcher : public PrivateDnsValidationObserver { // Drop any cache entries whose useCount is zero and which have not been used recently. // This function performs a linear scan of mStore. void cleanup(std::chrono::time_point<std::chrono::steady_clock> now, std::chrono::seconds unusable_xport_idle_timeout, std::optional<unsigned> netId) REQUIRES(sLock); std::optional<unsigned> netId) REQUIRES(sLock); // Return a sorted list of usable DnsTlsServers in preference order. std::list<DnsTlsServer> getOrderedAndUsableServerList(const std::list<DnsTlsServer>& tlsServers, Loading Experiments.h +0 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ class Experiments { "sort_nameservers", "dot_async_handshake", "dot_connect_timeout_ms", "dot_keep_unusable_xport_sec", "dot_maxtries", "dot_revalidation_threshold", "dot_xport_unusable_threshold", Loading PrivateDnsConfiguration.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -301,11 +301,8 @@ bool PrivateDnsConfiguration::recordPrivateDnsValidation(const ServerIdentity& i } bool reevaluationStatus = NEEDS_REEVALUATION; if (success) { reevaluationStatus = DONT_REEVALUATE; } else if (mode->second == PrivateDnsMode::OFF) { reevaluationStatus = DONT_REEVALUATE; } else if (mode->second == PrivateDnsMode::OPPORTUNISTIC && !isRevalidation) { if (success || (mode->second == PrivateDnsMode::OFF) || (mode->second == PrivateDnsMode::OPPORTUNISTIC && !isRevalidation)) { reevaluationStatus = DONT_REEVALUATE; } Loading apex/manifest.json +1 −1 Original line number Diff line number Diff line { "name": "com.android.resolv", "version": 330511000 "version": 330513000 } Loading
DnsTlsDispatcher.cpp +3 −23 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ #include "resolv_cache.h" #include "resolv_private.h" #include "stats.pb.h" #include "util.h" #include <android-base/logging.h> Loading Loading @@ -244,7 +243,7 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const DnsTlsServer& server, un void DnsTlsDispatcher::forceCleanup(unsigned netId) { std::lock_guard guard(sLock); cleanup(std::chrono::steady_clock::now(), std::chrono::seconds(-1), netId); cleanup(std::chrono::steady_clock::now(), netId); } DnsTlsTransport::Result DnsTlsDispatcher::queryInternal(Transport& xport, Loading Loading @@ -277,41 +276,22 @@ DnsTlsTransport::Result DnsTlsDispatcher::queryInternal(Transport& xport, // This timeout effectively controls how long to keep SSL session tickets. static constexpr std::chrono::minutes IDLE_TIMEOUT(5); void DnsTlsDispatcher::maybeCleanup(std::chrono::time_point<std::chrono::steady_clock> now) { // Make the timeout tunable via experiment flag for testing. std::chrono::seconds unusable_xport_idle_timeout{-1}; const int value = Experiments::getInstance()->getFlag("dot_keep_unusable_xport_sec", -1); if (value > -1 && isUserDebugBuild() && std::chrono::seconds(value) < IDLE_TIMEOUT) { unusable_xport_idle_timeout = std::chrono::seconds(value); } // To avoid scanning mStore after every query, return early if a cleanup has been // performed recently. const std::chrono::seconds timeout = (unusable_xport_idle_timeout < IDLE_TIMEOUT) ? unusable_xport_idle_timeout : IDLE_TIMEOUT; if (now - mLastCleanup < timeout) { if (now - mLastCleanup < IDLE_TIMEOUT) { return; } cleanup(now, unusable_xport_idle_timeout, std::nullopt); cleanup(now, std::nullopt); mLastCleanup = now; } void DnsTlsDispatcher::cleanup(std::chrono::time_point<std::chrono::steady_clock> now, std::chrono::seconds unusable_xport_idle_timeout, std::optional<unsigned> netId) { std::erase_if(mStore, [&](const auto& item) REQUIRES(sLock) { auto const& [_, xport] = item; if (xport->useCount == 0) { // Remove the Transports of the associated network. if (netId.has_value() && xport->mNetId == netId.value()) return true; // Remove all expired Transports. if (now - xport->lastUsed > IDLE_TIMEOUT) return true; // Unusable Transports should be removed earlier. if (!xport->usable() && unusable_xport_idle_timeout.count() >= 0 && now - xport->lastUsed > unusable_xport_idle_timeout) return true; } return false; }); Loading
DnsTlsDispatcher.h +1 −2 Original line number Diff line number Diff line Loading @@ -165,8 +165,7 @@ class DnsTlsDispatcher : public PrivateDnsValidationObserver { // Drop any cache entries whose useCount is zero and which have not been used recently. // This function performs a linear scan of mStore. void cleanup(std::chrono::time_point<std::chrono::steady_clock> now, std::chrono::seconds unusable_xport_idle_timeout, std::optional<unsigned> netId) REQUIRES(sLock); std::optional<unsigned> netId) REQUIRES(sLock); // Return a sorted list of usable DnsTlsServers in preference order. std::list<DnsTlsServer> getOrderedAndUsableServerList(const std::list<DnsTlsServer>& tlsServers, Loading
Experiments.h +0 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ class Experiments { "sort_nameservers", "dot_async_handshake", "dot_connect_timeout_ms", "dot_keep_unusable_xport_sec", "dot_maxtries", "dot_revalidation_threshold", "dot_xport_unusable_threshold", Loading
PrivateDnsConfiguration.cpp +2 −5 Original line number Diff line number Diff line Loading @@ -301,11 +301,8 @@ bool PrivateDnsConfiguration::recordPrivateDnsValidation(const ServerIdentity& i } bool reevaluationStatus = NEEDS_REEVALUATION; if (success) { reevaluationStatus = DONT_REEVALUATE; } else if (mode->second == PrivateDnsMode::OFF) { reevaluationStatus = DONT_REEVALUATE; } else if (mode->second == PrivateDnsMode::OPPORTUNISTIC && !isRevalidation) { if (success || (mode->second == PrivateDnsMode::OFF) || (mode->second == PrivateDnsMode::OPPORTUNISTIC && !isRevalidation)) { reevaluationStatus = DONT_REEVALUATE; } Loading
apex/manifest.json +1 −1 Original line number Diff line number Diff line { "name": "com.android.resolv", "version": 330511000 "version": 330513000 }