Bug 1703934 - P1: restart pending transactions when an error happened before connect, r=dragana,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D112348
This commit is contained in:
Kershaw Chang 2021-04-21 08:59:20 +00:00
Родитель 024220247f
Коммит 99aa63309a
3 изменённых файлов: 77 добавлений и 2 удалений

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

@ -3401,6 +3401,9 @@ void nsHttpConnectionMgr::ExcludeHttp3(const nsHttpConnectionInfo* ci) {
}
ent->DontReuseHttp3Conn();
// Need to cancel the transactions in the pending queue. Otherwise, they'll
// stay in the queue forever.
ent->CancelAllTransactions(NS_ERROR_NET_RESET);
}
void nsHttpConnectionMgr::MoveToWildCardConnEntry(

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

@ -481,7 +481,8 @@ static inline void CreateAndStartTimer(nsCOMPtr<nsITimer>& aTimer,
void nsHttpTransaction::OnPendingQueueInserted() {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (mConnInfo->IsHttp3() && !mResolver) {
// Don't create mHttp3BackupTimer if HTTPS RR is in play.
if (mConnInfo->IsHttp3() && !mOrigConnInfo) {
// Backup timer should only be created once.
if (!mHttp3BackupTimerCreated) {
CreateAndStartTimer(mHttp3BackupTimer, this,
@ -3132,7 +3133,7 @@ nsresult nsHttpTransaction::OnHTTPSRRAvailable(
RefPtr<nsHttpConnectionInfo> newInfo =
mConnInfo->CloneAndAdoptHTTPSSVCRecord(svcbRecord);
bool needFastFallback = !mConnInfo->IsHttp3() && newInfo->IsHttp3();
bool needFastFallback = newInfo->IsHttp3();
if (!gHttpHandler->ConnMgr()->MoveTransToNewConnEntry(this, newInfo)) {
// MoveTransToNewConnEntry() returning fail means this transaction is
// not in the connection entry's pending queue. This could happen if
@ -3142,6 +3143,9 @@ nsresult nsHttpTransaction::OnHTTPSRRAvailable(
UpdateConnectionInfo(newInfo);
}
// In case we already have mHttp3BackupTimer, cancel it.
MaybeCancelFallbackTimer();
if (needFastFallback) {
CreateAndStartTimer(
mFastFallbackTimer, this,

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

@ -630,3 +630,71 @@ add_task(async function testFastfallbackWithoutEchConfig() {
await trrServer.stop();
});
add_task(async function testH3FallbackWithMultipleTransactions() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setBoolPref("network.dns.upgrade_with_https_rr", true);
Services.prefs.setBoolPref("network.dns.use_https_rr_as_altsvc", true);
Services.prefs.setBoolPref("network.dns.echconfig.enabled", false);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref(
"network.trr.uri",
`https://foo.example.com:${trrServer.port}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enabled", true);
// Disable fast fallback.
Services.prefs.setIntPref(
"network.dns.httpssvc.http3_fast_fallback_timeout",
0
);
await trrServer.registerDoHAnswers("test.multiple_trans.org", "HTTPS", {
answers: [
{
name: "test.multiple_trans.org",
ttl: 55,
type: "HTTPS",
flush: false,
data: {
priority: 1,
name: "test.multiple_trans.org",
values: [
{ key: "alpn", value: "h3-27" },
{ key: "port", value: h3Port },
],
},
},
],
});
await trrServer.registerDoHAnswers("test.multiple_trans.org", "A", {
answers: [
{
name: "test.multiple_trans.org",
ttl: 55,
type: "A",
flush: false,
data: "127.0.0.1",
},
],
});
let promises = [];
for (let i = 0; i < 2; ++i) {
let chan = makeChan(`https://test.multiple_trans.org:${h2Port}/server-timing`);
promises.push(channelOpenPromise(chan))
}
let res = await Promise.all(promises);
res.forEach(function(e) {
let [req] = e;
Assert.equal(req.protocolVersion, "h2");
let internal = req.QueryInterface(Ci.nsIHttpChannelInternal);
Assert.equal(internal.remotePort, h2Port);
});
await trrServer.stop();
});