From fb5ff98d320b1ca4c93e4553a82b1f4046336a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 15 Mar 2024 12:34:36 +0100 Subject: [PATCH] Http2: fix streamsToUse logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The settings frame with the max streams might be received late or be revised later, so we cannot assert something on the relation with the max streams allowed. Amends 22c99cf498103c86baa5a415ca34630396e5b6aa Change-Id: I973dfcf91541becc8c3d6363f9065bb1b9183062 Reviewed-by: Øystein Heskestad Reviewed-by: Timur Pocheptsov (cherry picked from commit b0b2b7d39d9689dfdcb69394d2c1b3a3e20f9999) Reviewed-by: Qt Cherry-pick Bot --- src/network/access/qhttp2protocolhandler.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 8f83b98b3e0..d17b62565ee 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -325,11 +325,10 @@ bool QHttp2ProtocolHandler::sendRequest() initReplyFromPushPromise(message, key); } - Q_ASSERT(qint64(maxConcurrentStreams) >= activeStreams.size()); - const size_t streamsToUse = std::min(maxConcurrentStreams - size_t(activeStreams.size()), - size_t(requests.size())); + const qint64 streamsToUse = qBound(0, qint64(maxConcurrentStreams) - activeStreams.size(), + requests.size()); auto it = requests.begin(); - for (size_t i = 0; i < streamsToUse; ++i) { + for (qint64 i = 0; i < streamsToUse; ++i) { const qint32 newStreamID = createNewStream(*it); if (!newStreamID) { // TODO: actually we have to open a new connection.