bug 737155 - httpconnectionmgr::processPendingQ allow more than 1 with pipeline r=honzab
authorPatrick McManus <mcmanus@ducksong.com>
Tue, 20 Mar 2012 13:11:32 -0400
changeset 89843 f7e1d343d3a6ba654beaa94695dd8c65df105c92
parent 89842 72f7ac5a2581e05e882a92abb8c909e6ad962598
child 89844 7239ac34e1296db9c7d0866575246d9b91d08f0f
push id7343
push usermcmanus@ducksong.com
push dateTue, 20 Mar 2012 17:34:38 +0000
treeherdermozilla-inbound@672cc4ee2dd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs737155
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 737155 - httpconnectionmgr::processPendingQ allow more than 1 with pipeline r=honzab
netwerk/protocol/http/nsHttpConnectionMgr.cpp
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -865,21 +865,24 @@ nsHttpConnectionMgr::ProcessPendingQForE
 {
     NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     LOG(("nsHttpConnectionMgr::ProcessPendingQForEntry [ci=%s]\n",
          ent->mConnInfo->HashKey().get()));
 
     ProcessSpdyPendingQ(ent);
 
-    PRInt32 count = ent->mPendingQ.Length();
+    PRUint32 count = ent->mPendingQ.Length();
     nsHttpTransaction *trans;
     nsresult rv;
-    
-    for (PRInt32 i = 0; i < count; ++i) {
+    bool dispatchedSuccessfully = false;
+
+    // iterate the pending list until one is dispatched successfully. Keep
+    // iterating afterwards only until a transaction fails to dispatch.
+    for (PRUint32 i = 0; i < count; ++i) {
         trans = ent->mPendingQ[i];
 
         // When this transaction has already established a half-open
         // connection, we want to prevent any duplicate half-open
         // connections from being established and bound to this
         // transaction. Allow only use of an idle persistent connection
         // (if found) for transactions referred by a half-open connection.
         bool alreadyHalfOpen = false;
@@ -890,18 +893,26 @@ nsHttpConnectionMgr::ProcessPendingQForE
             }
         }
 
         rv = TryDispatchTransaction(ent, alreadyHalfOpen, trans);
         if (NS_SUCCEEDED(rv)) {
             LOG(("  dispatching pending transaction...\n"));
             ent->mPendingQ.RemoveElementAt(i);
             NS_RELEASE(trans);
+
+            // reset index and array length after RemoveElelmentAt()
+            dispatchedSuccessfully = true;
+            count = ent->mPendingQ.Length();
+            --i;
+            continue;
+        }
+
+        if (dispatchedSuccessfully)
             return true;
-        }
 
         NS_ABORT_IF_FALSE(count == ((PRInt32) ent->mPendingQ.Length()),
                           "something mutated pending queue from "
                           "GetConnection()");
     }
     return false;
 }