From 9440d602e5b236e4981899aa7698578778065166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 28 Aug 2020 17:23:27 +0200 Subject: QNAM: fix stall due to edge case when connected with no request queued It really could only manifest itself if you started a request and then immediately cancelled it and then started another one to the same site. But only if in a certain race outcome - the connection that the backend was establishing had to finish connecting after aborting but before a new request had been queued! Change-Id: I7cad2cf4ac1f64cc838498cefa076cd2c6d26701 Reviewed-by: Alex Blasche Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnection.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/network/access') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index ff95a49965..24be5b1464 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1066,8 +1066,18 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() channels[0].networkLayerPreference = QAbstractSocket::IPv6Protocol; channels[0].ensureConnection(); if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState - && !channels[0].pendingEncrypt && channels[0].h2RequestsToSend.size()) - channels[0].sendRequest(); + && !channels[0].pendingEncrypt) { + if (channels[0].h2RequestsToSend.size()) { + channels[0].sendRequest(); + } else if (!channels[0].reply && !channels[0].switchedToHttp2) { + // This covers an edge-case where we're already connected and the "connected" + // signal was already sent, but we didn't have any request available at the time, + // so it was missed. As such we need to dequeue a request and send it now that we + // have one. + dequeueRequest(channels[0].socket); + channels[0].sendRequest(); + } + } break; } } -- cgit v1.2.3