summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttp2protocolhandler.cpp
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2024-02-07 18:56:19 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2024-03-18 17:42:19 +0100
commit5ed736b053eb9d04ecd1a6f2f375cce7fcefe4e6 (patch)
tree71e1370d565853fdd15991c74ed3cbc97323b1e7 /src/network/access/qhttp2protocolhandler.cpp
parentb0b2b7d39d9689dfdcb69394d2c1b3a3e20f9999 (diff)
Http/2: fix active streams counting
We were looking at all active streams, but that also includes promised streams. By the RFC the limitation that our peer specifies only applies to the number of streams _we_ create, not the total amount of active streams. More importantly, for the qhttp2protocolhandler it could mean that we could end up having a few promised streams push the active stream count over the limit, which could lead us to start more streams than intended (then bounded by the number of queued requests). The worst case in this scenario is that a **non-compliant** server doesn't track how many connections we open and the user has queued a ton of requests, so we open a ton of streams. But on the upside: server-push is not widely used. Pick-to: 6.7 Change-Id: I2a533472eb9127fd176bb99e9db0518f05c3fffe Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r--src/network/access/qhttp2protocolhandler.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
index b2b3676fd7..376f7251ff 100644
--- a/src/network/access/qhttp2protocolhandler.cpp
+++ b/src/network/access/qhttp2protocolhandler.cpp
@@ -326,7 +326,10 @@ bool QHttp2ProtocolHandler::sendRequest()
initReplyFromPushPromise(message, key);
}
- const qint64 streamsToUse = qBound(0, qint64(maxConcurrentStreams) - activeStreams.size(),
+ const auto isClientSide = [](const auto &pair) -> bool { return (pair.first & 1) == 1; };
+ const auto activeClientSideStreams = std::count_if(
+ activeStreams.constKeyValueBegin(), activeStreams.constKeyValueEnd(), isClientSide);
+ const qint64 streamsToUse = qBound(0, qint64(maxConcurrentStreams) - activeClientSideStreams,
requests.size());
auto it = requests.begin();
for (qint64 i = 0; i < streamsToUse; ++i) {