Bug 1564310 - Allow fallback in strict mode for request timeouts r=necko-reviewers,kershaw

We don't actually want to fail requests that time out. So if the retry
also times out we just fallback to native as usual.

Depends on D137931

Differential Revision: https://phabricator.services.mozilla.com/D137932
This commit is contained in:
Valentin Gosu 2022-02-07 09:04:45 +00:00
Родитель 5337335d54
Коммит 613521582a
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -10218,6 +10218,12 @@
value: false
mirror: always
# If true, we'll fallback to native if the retry also times out.
- name: network.trr.strict_native_fallback_allow_timeouts
type: RelaxedAtomicBool
value: true
mirror: always
# Single TRR request timeout (ms) when strict native fallback is enabled.
- name: network.trr.strict_fallback_request_timeout_ms
type: RelaxedAtomicUint32

Просмотреть файл

@ -1337,6 +1337,13 @@ bool nsHostResolver::MaybeRetryTRRLookup(
}
if (aAddrRec->mTrrAttempts > 1) {
if (aFirstAttemptSkipReason == TRRSkippedReason::TRR_TIMEOUT &&
StaticPrefs::network_trr_strict_native_fallback_allow_timeouts()) {
LOG(
("nsHostResolver::MaybeRetryTRRLookup retry timed out. Using "
"native."));
return NS_SUCCEEDED(NativeLookup(aAddrRec, aLock));
}
LOG(("nsHostResolver::MaybeRetryTRRLookup mTrrAttempts>1, not retrying."));
return false;
}

Просмотреть файл

@ -249,6 +249,11 @@ async function test_strict_native_fallback() {
10
);
Services.prefs.setBoolPref(
"network.trr.strict_native_fallback_allow_timeouts",
false
);
let { inStatus } = await new TRRDNSListener(
"timeout.example.com",
undefined,
@ -258,6 +263,22 @@ async function test_strict_native_fallback() {
!Components.isSuccessCode(inStatus),
`${inStatus} should be an error code`
);
dns.clearCache(true);
await new TRRDNSListener("timeout.example.com", undefined, false);
dns.clearCache(true);
Services.prefs.setBoolPref(
"network.trr.strict_native_fallback_allow_timeouts",
true
);
await new TRRDNSListener("timeout.example.com", {
expectedAnswer: "127.0.0.1",
});
Services.prefs.setBoolPref(
"network.trr.strict_native_fallback_allow_timeouts",
false
);
info("Now a connection error");
dns.clearCache(true);