Skip to content

Commit 7496c85

Browse files
committed
Revert "Bug 1999691 - When a DNS cache entry is used, take it out and readd it to the eviction queue, r=necko-reviewers,valentin" for causing a top crash tracked under Bug 2004939.
This reverts commit ffb7bd5.
1 parent a2586e4 commit 7496c85

File tree

7 files changed

+13
-172
lines changed

7 files changed

+13
-172
lines changed

modules/libpref/init/StaticPrefList.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15666,13 +15666,6 @@
1566615666
value: ""
1566715667
mirror: never
1566815668

15669-
# When true, placing the most recent used cache entry
15670-
# to the tail of the EvictionQ.
15671-
- name: network.dns.mru_to_tail
15672-
type: RelaxedAtomicBool
15673-
value: @IS_NIGHTLY_BUILD@
15674-
mirror: always
15675-
1567615669
# Whether to add additional record IPs to the cache
1567715670
- name: network.trr.add_additional_records
1567815671
type: RelaxedAtomicBool

netwerk/dns/HostRecordQueue.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,6 @@ void HostRecordQueue::AddToEvictionQ(
9292
}
9393
}
9494

95-
void HostRecordQueue::MoveToEvictionQueueTail(
96-
nsHostRecord* aRec, const MutexAutoLock& aProofOfLock) {
97-
bool inEvictionQ = mEvictionQ.contains(aRec);
98-
if (!inEvictionQ) {
99-
// Note: this function can be called when the record isn’t in the
100-
// mEvictionQ. For example, if we immediately start a TTL lookup (see
101-
// nsHostResolver::CompleteLookupLocked), the record may not be in
102-
// mEvictionQ.
103-
return;
104-
}
105-
106-
aRec->remove();
107-
mEvictionQ.insertBack(aRec);
108-
}
109-
11095
void HostRecordQueue::MaybeRenewHostRecord(nsHostRecord* aRec,
11196
const MutexAutoLock& aProofOfLock) {
11297
if (!aRec->isInList()) {

netwerk/dns/HostRecordQueue.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ class HostRecordQueue final {
3434
nsHostRecord* aRec, uint32_t aMaxCacheEntries,
3535
nsRefPtrHashtable<nsGenericHashKey<nsHostKey>, nsHostRecord>& aDB,
3636
const MutexAutoLock& aProofOfLock);
37-
38-
// Move aRec to the tail of mEvictionQ (the most-recently-used end).
39-
void MoveToEvictionQueueTail(nsHostRecord* aRec,
40-
const MutexAutoLock& aProofOfLock);
41-
4237
// Called for removing the record from mEvictionQ. When this function is
4338
// called, the record should be either in mEvictionQ or not in any queue.
4439
void MaybeRenewHostRecord(nsHostRecord* aRec,

netwerk/dns/nsHostResolver.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost,
591591
} else if (!rec->mResolving) {
592592
result =
593593
FromUnspecEntry(rec, host, aTrrServer, originSuffix, type, flags, af,
594-
aOriginAttributes.IsPrivateBrowsing(), status, lock);
594+
aOriginAttributes.IsPrivateBrowsing(), status);
595595
// If this is a by-type request or if no valid record was found
596596
// in the cache or this is an AF_UNSPEC request, then start a
597597
// new lookup.
@@ -675,14 +675,12 @@ already_AddRefed<nsHostRecord> nsHostResolver::FromCache(
675675
// but start a new lookup in the background.
676676
//
677677
// Also records telemetry for type of cache hit (HIT/NEGATIVE_HIT/RENEWAL).
678-
bool refresh = ConditionallyRefreshRecord(aRec, aHost, aLock);
678+
ConditionallyRefreshRecord(aRec, aHost, aLock);
679679

680680
if (aRec->negative) {
681681
LOG((" Negative cache entry for host [%s].\n",
682682
nsPromiseFlatCString(aHost).get()));
683683
aStatus = NS_ERROR_UNKNOWN_HOST;
684-
} else if (StaticPrefs::network_dns_mru_to_tail() && !refresh) {
685-
mQueue.MoveToEvictionQueueTail(aRec, aLock);
686684
}
687685

688686
return result.forget();
@@ -709,8 +707,7 @@ already_AddRefed<nsHostRecord> nsHostResolver::FromIPLiteral(
709707
already_AddRefed<nsHostRecord> nsHostResolver::FromUnspecEntry(
710708
nsHostRecord* aRec, const nsACString& aHost, const nsACString& aTrrServer,
711709
const nsACString& aOriginSuffix, uint16_t aType,
712-
nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus,
713-
const MutexAutoLock& aLock) {
710+
nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus) {
714711
RefPtr<nsHostRecord> result = nullptr;
715712
// If this is an IPV4 or IPV6 specific request, check if there is
716713
// an AF_UNSPEC entry we can use. Otherwise, hit the resolver...
@@ -776,10 +773,7 @@ already_AddRefed<nsHostRecord> nsHostResolver::FromUnspecEntry(
776773
if (aRec->negative) {
777774
aStatus = NS_ERROR_UNKNOWN_HOST;
778775
}
779-
bool refresh = ConditionallyRefreshRecord(aRec, aHost, lock);
780-
if (!refresh) {
781-
AddToEvictionQ(result, aLock);
782-
}
776+
ConditionallyRefreshRecord(aRec, aHost, lock);
783777
} else if (af == PR_AF_INET6) {
784778
// For AF_INET6, a new lookup means another AF_UNSPEC
785779
// lookup. We have already iterated through the
@@ -1189,15 +1183,14 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec,
11891183
return rv;
11901184
}
11911185

1192-
bool nsHostResolver::ConditionallyRefreshRecord(nsHostRecord* rec,
1193-
const nsACString& host,
1194-
const MutexAutoLock& aLock) {
1186+
nsresult nsHostResolver::ConditionallyRefreshRecord(
1187+
nsHostRecord* rec, const nsACString& host, const MutexAutoLock& aLock) {
11951188
if ((rec->CheckExpiration(TimeStamp::NowLoRes()) == nsHostRecord::EXP_GRACE ||
11961189
rec->negative) &&
11971190
!rec->mResolving && rec->RefreshForNegativeResponse()) {
11981191
LOG((" Using %s cache entry for host [%s] but starting async renewal.",
11991192
rec->negative ? "negative" : "positive", host.BeginReading()));
1200-
nsresult rv = NameLookup(rec, aLock);
1193+
NameLookup(rec, aLock);
12011194

12021195
if (rec->IsAddrRecord()) {
12031196
if (!rec->negative) {
@@ -1206,8 +1199,6 @@ bool nsHostResolver::ConditionallyRefreshRecord(nsHostRecord* rec,
12061199
glean::dns::lookup_method.AccumulateSingleSample(METHOD_NEGATIVE_HIT);
12071200
}
12081201
}
1209-
1210-
return NS_SUCCEEDED(rv);
12111202
} else if (rec->IsAddrRecord()) {
12121203
// it could be that the record is negative, but we haven't entered the above
12131204
// if condition due to the second expression being false. In that case we
@@ -1219,7 +1210,7 @@ bool nsHostResolver::ConditionallyRefreshRecord(nsHostRecord* rec,
12191210
}
12201211
}
12211212

1222-
return false;
1213+
return NS_OK;
12231214
}
12241215

12251216
bool nsHostResolver::GetHostToLookup(nsHostRecord** result) {

netwerk/dns/nsHostResolver.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,12 @@ class nsHostResolver : public nsISupports, public AHostResolver {
234234

235235
/**
236236
* Starts a new lookup in the background for cached entries that are in the
237-
* grace period or that are are negative. Return true when the new lookup
238-
* starts.
237+
* grace period or that are are negative.
239238
*
240239
* Also records telemetry for type of cache hit (HIT/NEGATIVE_HIT/RENEWAL).
241240
*/
242-
bool ConditionallyRefreshRecord(nsHostRecord* rec, const nsACString& host,
243-
const mozilla::MutexAutoLock& aLock)
241+
nsresult ConditionallyRefreshRecord(nsHostRecord* rec, const nsACString& host,
242+
const mozilla::MutexAutoLock& aLock)
244243
MOZ_REQUIRES(mLock);
245244

246245
void OnResolveComplete(nsHostRecord* aRec,
@@ -267,8 +266,8 @@ class nsHostResolver : public nsISupports, public AHostResolver {
267266
already_AddRefed<nsHostRecord> FromUnspecEntry(
268267
nsHostRecord* aRec, const nsACString& aHost, const nsACString& aTrrServer,
269268
const nsACString& aOriginSuffix, uint16_t aType,
270-
nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus,
271-
const mozilla::MutexAutoLock& aLock) MOZ_REQUIRES(mLock);
269+
nsIDNSService::DNSFlags aFlags, uint16_t af, bool aPb, nsresult& aStatus)
270+
MOZ_REQUIRES(mLock);
272271

273272
enum {
274273
METHOD_HIT = 1,

netwerk/test/gtest/TestHostRecordQueue.cpp

Lines changed: 0 additions & 120 deletions
This file was deleted.

netwerk/test/gtest/moz.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ UNIFIED_SOURCES += [
1616
"TestDNSPacket.cpp",
1717
"TestEtcHostsParsing.cpp",
1818
"TestHeaders.cpp",
19-
"TestHostRecordQueue.cpp",
2019
"TestHttp2WebTransport.cpp",
2120
"TestHttp3ConnectUDPStream.cpp",
2221
"TestHttpAtom.cpp",
@@ -70,7 +69,6 @@ LOCAL_INCLUDES += [
7069
"/netwerk/base",
7170
"/netwerk/cache2",
7271
"/netwerk/cookie",
73-
"/netwerk/dns",
7472
"/netwerk/protocol/http",
7573
"/toolkit/components/jsoncpp/include",
7674
"/xpcom/tests/gtest",

0 commit comments

Comments
 (0)