diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 66f9961028eb..3aae4b86d2e0 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -2071,6 +2071,13 @@ VARCACHE_PREF( uint32_t, 0 ) +// Max time to shutdown the resolver threads +VARCACHE_PREF( + "network.dns.resolver_shutdown_timeout_ms", + network_dns_resolver_shutdown_timeout_ms, + uint32_t, 2000 +) + //--------------------------------------------------------------------------- // ContentSessionStore prefs //--------------------------------------------------------------------------- diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 258bf9bda73f..feeb773bca51 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -44,6 +44,7 @@ #include "mozilla/Telemetry.h" #include "mozilla/DebugOnly.h" #include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" using namespace mozilla; using namespace mozilla::net; @@ -799,9 +800,10 @@ void nsHostResolver::Shutdown() { pendingQLow.clear(); evictionQ.clear(); - // Shutdown the resolver threads, but with a timeout of 20 seconds. + // Shutdown the resolver threads, but with a timeout of 2 seconds (prefable). // If the timeout is exceeded, any stuck threads will be leaked. - mResolverThreads->ShutdownWithTimeout(20 * 1000); + mResolverThreads->ShutdownWithTimeout( + StaticPrefs::network_dns_resolver_shutdown_timeout_ms()); { mozilla::DebugOnly rv = GetAddrInfoShutdown();