From 88f5fc47ebf558fa72b7b447f8394a0d44b6bf9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 9 Jan 2024 17:01:57 +0100 Subject: [PATCH] Http: Start more connections faster after determining network layer Previously we would more or less wait for the first connection to finish before initiating more connections. This was just happening by virtue of calling startNextRequest when a request was finished. Since we have already determined the preferred network layer, let's just try to start more connections. In case we are using https this doesn't make a difference because we will try http2 upgrade first before allowing multiple connections. Unless, of course, http2 has been disabled. Fixes: QTBUG-120619 Pick-to: 6.7 6.6 6.5 Change-Id: Id3c3be59fd07120bff574d63481119e5ed9eb88a Reviewed-by: Qt CI Bot Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 032a280467..6766989690 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -856,6 +856,8 @@ void QHttpNetworkConnectionChannel::_q_connected() connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; } connection->d_func()->networkLayerDetected(networkLayerPreference); + if (connection->d_func()->activeChannelCount > 1 && !connection->d_func()->encrypt) + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else { bool anyProtocol = networkLayerPreference == QAbstractSocket::AnyIPProtocol; if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) @@ -1240,7 +1242,6 @@ void QHttpNetworkConnectionChannel::_q_encrypted() emit pair.second->encrypted(); // In case our peer has sent us its settings (window size, max concurrent streams etc.) // let's give _q_receiveReply a chance to read them first ('invokeMethod', QueuedConnection). - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } } else { // HTTP if (!reply) @@ -1253,6 +1254,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() if (reply) sendRequestDelayed(); } + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } void QHttpNetworkConnectionChannel::requeueHttp2Requests()