diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-11 15:09:12 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-11 16:36:04 (GMT) |
commit | 14412557e7523ca39698ca4f4aa40ebe9c051d77 (patch) | |
tree | cbe745f327de8e44f30c986086aa24735e8776e8 /src/network | |
parent | a6592a167c2c4d2714d701e49d332217749124f4 (diff) | |
download | Qt-14412557e7523ca39698ca4f4aa40ebe9c051d77.zip Qt-14412557e7523ca39698ca4f4aa40ebe9c051d77.tar.gz Qt-14412557e7523ca39698ca4f4aa40ebe9c051d77.tar.bz2 |
QNAM HTTP Code: When starting new request, prefer connected sockets.
Prefer a QHttpNetworkConnectionChannel which has a connected socket
to a channel which doesn't have a connected socket.
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index b7dbeac..20baac8 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -691,19 +691,31 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() channels[i].sendRequest(); } } + + // dequeue new ones + QAbstractSocket *socket = 0; for (int i = 0; i < channelCount; ++i) { QAbstractSocket *chSocket = channels[i].socket; - // send the request using the idle socket - if (!channels[i].isSocketBusy()) { + // try to get a free AND connected socket + if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) { socket = chSocket; + dequeueAndSendRequest(socket); break; } } - // this socket is free, - if (socket) - dequeueAndSendRequest(socket); + if (!socket) { + for (int i = 0; i < channelCount; ++i) { + QAbstractSocket *chSocket = channels[i].socket; + // try to get a free unconnected socket + if (!channels[i].isSocketBusy()) { + socket = chSocket; + dequeueAndSendRequest(socket); + break; + } + } + } // try to push more into all sockets // ### FIXME we should move this to the beginning of the function |