bug 737155 - httpconnectionmgr::processPendingQ allow more than 1 with pipeline r=honzab
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 22 Mar 2012 19:39:31 -0400
changeset 90099 e83a04b972e9e858ae3a025a4ac0eac4286e1d22
parent 90098 ee6328d11bfbdb4522005db634ff4647768520d6
child 90100 e1e48e9ce79565e48f0b93ca75192976e92e379d
push id22312
push usermak77@bonardo.net
push dateFri, 23 Mar 2012 11:50:43 +0000
treeherdermozilla-central@c20ec27eb0e8 [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;
 }