From 7c336961ad6949dad98128eb8dda096780ca3204 Mon Sep 17 00:00:00 2001 From: Dragana Damjanovic Date: Tue, 4 Aug 2020 12:41:54 +0000 Subject: [PATCH] Bug 1655843 - Prefer HTTP3 connections in the connection pool. r=michal,necko-reviewers Differential Revision: https://phabricator.services.mozilla.com/D85843 --- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index e6a91e6434e7..597497ca96f6 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -839,13 +839,22 @@ void nsHttpConnectionMgr::UpdateCoalescingForNewConn( HttpConnectionBase* existingConn = FindCoalescableConnection(ent, true, false); if (existingConn) { - LOG( - ("UpdateCoalescingForNewConn() found existing active conn that could " - "have served newConn " - "graceful close of newConn=%p to migrate to existingConn %p\n", - newConn, existingConn)); - newConn->DontReuse(); - return; + // Prefer http3 connection. + if (newConn->UsingHttp3() && existingConn->UsingSpdy()) { + LOG( + ("UpdateCoalescingForNewConn() found existing active H2 conn that " + "could have served newConn, but new connection is H3, therefore " + "close the H2 conncetion")); + existingConn->DontReuse(); + } else { + LOG( + ("UpdateCoalescingForNewConn() found existing active conn that could " + "have served newConn " + "graceful close of newConn=%p to migrate to existingConn %p\n", + newConn, existingConn)); + newConn->DontReuse(); + return; + } } // This connection might go into the mCoalescingHash for new transactions to