зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450893 - Add way to clear DNS cache r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D24300 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
dee2f46076
Коммит
50597c68ef
|
@ -285,6 +285,9 @@ ChildDNSService::GetDNSCacheEntries(
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ChildDNSService::ClearCache(bool aTrrToo) { return NS_ERROR_NOT_AVAILABLE; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
ChildDNSService::GetMyHostName(nsACString &result) {
|
||||
// TODO: get value from parent during PNecko construction?
|
||||
|
|
|
@ -1131,7 +1131,7 @@ nsDNSService::Observe(nsISupports *subject, const char *topic,
|
|||
}
|
||||
|
||||
if (flushCache) {
|
||||
mResolver->FlushCache();
|
||||
mResolver->FlushCache(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1198,6 +1198,12 @@ nsDNSService::GetDNSCacheEntries(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSService::ClearCache(bool aTrrToo) {
|
||||
mResolver->FlushCache(aTrrToo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
size_t nsDNSService::SizeOfIncludingThis(
|
||||
mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
// Measurement of the following members may be added later if DMD finds it
|
||||
|
|
|
@ -385,10 +385,10 @@ void AddrHostRecord::Cancel() {
|
|||
|
||||
// Returns true if the entry can be removed, or false if it should be left.
|
||||
// Sets mResolveAgain true for entries being resolved right now.
|
||||
bool AddrHostRecord::RemoveOrRefresh() {
|
||||
bool AddrHostRecord::RemoveOrRefresh(bool aTrrToo) {
|
||||
// no need to flush TRRed names, they're not resolved "locally"
|
||||
MutexAutoLock lock(addr_info_lock);
|
||||
if (addr_info && addr_info->IsTRR()) {
|
||||
if (addr_info && !aTrrToo && addr_info->IsTRR()) {
|
||||
return false;
|
||||
}
|
||||
if (mNative) {
|
||||
|
@ -715,7 +715,7 @@ void nsHostResolver::ClearPendingQueue(
|
|||
// cache that have 'Resolve' set true but not 'onQueue' are being resolved
|
||||
// right now, so we need to mark them to get re-resolved on completion!
|
||||
|
||||
void nsHostResolver::FlushCache() {
|
||||
void nsHostResolver::FlushCache(bool aTrrToo) {
|
||||
MutexAutoLock lock(mLock);
|
||||
mEvictionQSize = 0;
|
||||
|
||||
|
@ -738,7 +738,7 @@ void nsHostResolver::FlushCache() {
|
|||
if (record->IsAddrRecord()) {
|
||||
RefPtr<AddrHostRecord> addrRec = do_QueryObject(record);
|
||||
MOZ_ASSERT(addrRec);
|
||||
if (addrRec->RemoveOrRefresh()) {
|
||||
if (addrRec->RemoveOrRefresh(aTrrToo)) {
|
||||
if (record->isInList()) {
|
||||
record->remove();
|
||||
}
|
||||
|
|
|
@ -204,8 +204,8 @@ class AddrHostRecord final : public nsHostRecord {
|
|||
|
||||
void Cancel() override;
|
||||
|
||||
bool RemoveOrRefresh(); // Mark records currently being resolved as needed
|
||||
// to resolve again.
|
||||
bool RemoveOrRefresh(bool aTrrToo); // Mark records currently being resolved
|
||||
// as needed to resolve again.
|
||||
|
||||
void ResolveComplete();
|
||||
|
||||
|
@ -475,7 +475,7 @@ class nsHostResolver : public nsISupports, public AHostResolver {
|
|||
/**
|
||||
* Flush the DNS cache.
|
||||
*/
|
||||
void FlushCache();
|
||||
void FlushCache(bool aTrrToo);
|
||||
|
||||
LookupStatus CompleteLookup(nsHostRecord *, nsresult,
|
||||
mozilla::net::AddrInfo *, bool pb,
|
||||
|
|
|
@ -212,6 +212,17 @@ interface nsIDNSService : nsISupports
|
|||
*/
|
||||
[noscript] void getDNSCacheEntries(in EntriesArray args);
|
||||
|
||||
|
||||
/**
|
||||
* Clears the DNS cache.
|
||||
* @param aTrrToo
|
||||
* If true we will clear TRR cached entries too. Since these
|
||||
* are resolved remotely it's not necessary to clear them when
|
||||
* the network status changes, but it's sometimes useful to do so
|
||||
* for tests or other situations.
|
||||
*/
|
||||
void clearCache(in boolean aTrrToo);
|
||||
|
||||
/**
|
||||
* @return the hostname of the operating system.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче