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.5
Change-Id: Id3c3be59fd07120bff574d63481119e5ed9eb88a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 88f5fc47ebf558fa72b7b447f8394a0d44b6bf9d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0002ba47e63151e37c15b61f0c0b809aefb378e1)
This commit is contained in:
Mårten Nordheim 2024-01-09 17:01:57 +01:00 committed by Qt Cherry-pick Bot
parent 57e98a4136
commit db447658b4

View File

@ -856,6 +856,8 @@ void QHttpNetworkConnectionChannel::_q_connected()
connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
} }
connection->d_func()->networkLayerDetected(networkLayerPreference); connection->d_func()->networkLayerDetected(networkLayerPreference);
if (connection->d_func()->activeChannelCount > 1 && !connection->d_func()->encrypt)
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} else { } else {
bool anyProtocol = networkLayerPreference == QAbstractSocket::AnyIPProtocol; bool anyProtocol = networkLayerPreference == QAbstractSocket::AnyIPProtocol;
if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4)
@ -1242,7 +1244,6 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
emit pair.second->encrypted(); emit pair.second->encrypted();
// In case our peer has sent us its settings (window size, max concurrent streams etc.) // 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). // let's give _q_receiveReply a chance to read them first ('invokeMethod', QueuedConnection).
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} }
} else { // HTTP } else { // HTTP
if (!reply) if (!reply)
@ -1255,6 +1256,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
if (reply) if (reply)
sendRequestDelayed(); sendRequestDelayed();
} }
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} }
void QHttpNetworkConnectionChannel::requeueHttp2Requests() void QHttpNetworkConnectionChannel::requeueHttp2Requests()