summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkconnection.cpp
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2023-10-04 17:54:33 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2023-10-16 19:28:26 +0200
commit13c4e11c49d16d6a83a142215d28e1ec660e1bba (patch)
tree5111e02327b0504453392f14dc2b6d65ba236dcc /src/network/access/qhttpnetworkconnection.cpp
parent80d4d55e250af1d643805bde3821987112cf09c1 (diff)
http2: When a reply is removed from the queue, only remove one
We were using the .remove(Key) API on the map instead of erase(iterator), so we were removing any reply of the same priority that had not yet been popped from the queues. Rewrote to drop loop and only work with iterators. This issue was there since SPDY days, so not picking all the way back to 5.15, where HTTP2 anyway is not enabled by default. As a drive-by, drop the #ifndef QT_NO_SSL, which was also there from SPDY times, which was TLS-only. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-116167 Change-Id: Id7e1eb311e009b86054c1fe3d049c760d711a18a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/access/qhttpnetworkconnection.cpp')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 74034ebcd3..8a7a6989f4 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -990,19 +990,18 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)
return;
}
}
-#ifndef QT_NO_SSL
// is the reply inside the H2 pipeline of this channel already?
- QMultiMap<int, HttpMessagePair>::iterator it = channels[i].h2RequestsToSend.begin();
- QMultiMap<int, HttpMessagePair>::iterator end = channels[i].h2RequestsToSend.end();
- for (; it != end; ++it) {
- if (it.value().second == reply) {
- channels[i].h2RequestsToSend.remove(it.key());
-
- QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
- return;
- }
+ const auto foundReply = [reply](const HttpMessagePair &pair) {
+ return pair.second == reply;
+ };
+ auto &seq = channels[i].h2RequestsToSend;
+ const auto end = seq.cend();
+ auto it = std::find_if(seq.cbegin(), end, foundReply);
+ if (it != end) {
+ seq.erase(it);
+ QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
+ return;
}
-#endif
}
// remove from the high priority queue
if (!highPriorityQueue.isEmpty()) {