From 14412557e7523ca39698ca4f4aa40ebe9c051d77 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 11 Jan 2010 16:09:12 +0100 Subject: 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 --- src/network/access/qhttpnetworkconnection.cpp | 22 +++++++++++++++++----- 1 file 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 -- cgit v0.12