From 75e9c7d6bc662e62e9ce8b641588183992c1e8bf Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 13 Jun 2013 11:53:35 +0200 Subject: [PATCH] HTTP internals: consider SSL sockets with pending encryption as usable We do not decide which socket a HTTP request is sent on until the socket is actually ready for sending a request (i.e. it is connected for HTTP requests and encryption is done for HTTPS requests). When deciding how many sockets we need for the queued requests, we consider an in-flight socket as free if it is still connecting. However, we considered a socket that was connected but needed to complete encryption as busy, and would instead open another socket. Now, we consider an encrypting socket as in-flight as well. Change-Id: I93d6743da6fc430d1424c6965e1475865fd97243 Reviewed-by: Richard J. Moore --- src/network/access/qhttpnetworkconnection.cpp | 4 +++- src/network/access/qhttpnetworkconnectionchannel.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index a279990f4cd..5c3c38606de 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -929,7 +929,9 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() for (int i = 0; i < channelCount; ++i) { bool connectChannel = false; if (channels[i].socket) { - if ((channels[i].socket->state() == QAbstractSocket::ConnectingState) || (channels[i].socket->state() == QAbstractSocket::HostLookupState)) + if ((channels[i].socket->state() == QAbstractSocket::ConnectingState) + || (channels[i].socket->state() == QAbstractSocket::HostLookupState) + || channels[i].pendingEncrypt) // pendingEncrypt == "EncryptingState" queuedRequest--; if ( queuedRequest <=0 ) break; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 53436b1769e..a756f22937b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -183,6 +183,9 @@ void QHttpNetworkConnectionChannel::close() else state = QHttpNetworkConnectionChannel::ClosingState; + // pendingEncrypt must only be true in between connected and encrypted states + pendingEncrypt = false; + if (socket) socket->close(); }