src/network/access/qhttpnetworkconnection.cpp
changeset 25 e24348a560a6
parent 23 89e065397ea6
child 30 5dc02b23752f
equal deleted inserted replaced
23:89e065397ea6 25:e24348a560a6
   714 
   714 
   715 
   715 
   716 
   716 
   717 // This function must be called from the event loop. The only
   717 // This function must be called from the event loop. The only
   718 // exception is documented in QHttpNetworkConnectionPrivate::queueRequest
   718 // exception is documented in QHttpNetworkConnectionPrivate::queueRequest
       
   719 // although it is called _q_startNextRequest, it will actually start multiple requests when possible
   719 void QHttpNetworkConnectionPrivate::_q_startNextRequest()
   720 void QHttpNetworkConnectionPrivate::_q_startNextRequest()
   720 {
   721 {
   721     //resend the necessary ones.
   722     //resend the necessary ones.
   722     for (int i = 0; i < channelCount; ++i) {
   723     for (int i = 0; i < channelCount; ++i) {
   723         if (channels[i].resendCurrent) {
   724         if (channels[i].resendCurrent) {
   731         }
   732         }
   732     }
   733     }
   733 
   734 
   734     // dequeue new ones
   735     // dequeue new ones
   735 
   736 
   736     QAbstractSocket *socket = 0;
   737     // return fast if there is nothing to do
       
   738     if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
       
   739         return;
       
   740     // try to get a free AND connected socket
   737     for (int i = 0; i < channelCount; ++i) {
   741     for (int i = 0; i < channelCount; ++i) {
   738         QAbstractSocket *chSocket = channels[i].socket;
       
   739         // try to get a free AND connected socket
       
   740         if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
   742         if (!channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
   741             socket = chSocket;
   743             dequeueAndSendRequest(channels[i].socket);
   742             dequeueAndSendRequest(socket);
   744         }
   743             break;
   745     }
   744         }
   746 
   745     }
   747     // return fast if there is nothing to do
   746 
   748     if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
   747     if (!socket) {
   749         return;
   748         for (int i = 0; i < channelCount; ++i) {
   750     // try to get a free unconnected socket
   749             QAbstractSocket *chSocket = channels[i].socket;
   751     for (int i = 0; i < channelCount; ++i) {
   750             // try to get a free unconnected socket
   752         if (!channels[i].isSocketBusy()) {
   751             if (!channels[i].isSocketBusy()) {
   753             dequeueAndSendRequest(channels[i].socket);
   752                 socket = chSocket;
       
   753                 dequeueAndSendRequest(socket);
       
   754                 break;
       
   755             }
       
   756         }
   754         }
   757     }
   755     }
   758 
   756 
   759     // try to push more into all sockets
   757     // try to push more into all sockets
   760     // ### FIXME we should move this to the beginning of the function
   758     // ### FIXME we should move this to the beginning of the function