diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-08-28 17:23:27 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-09-10 03:18:02 +0200 |
commit | 9440d602e5b236e4981899aa7698578778065166 (patch) | |
tree | 36db0be6f31955c1fe1fc79278432756989232d0 /src/network/access | |
parent | bbec7aaf3a8cf81f28810db2270c787cc9910268 (diff) |
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 <alexander.blasche@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
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; } } |