Bug 653530 - HTTP Transaction multiply dispatched r=honzab

--HG--
extra : rebase_source : 6ba6ea647bd83154f03ded03ec4fc88580fc8f2f
This commit is contained in:
Patrick McManus 2011-04-29 15:32:40 -04:00
parent 185fd26c4f
commit ae39c259af
2 changed files with 26 additions and 3 deletions

View File

@ -561,7 +561,21 @@ nsHttpConnectionMgr::ProcessPendingQForEntry(nsConnectionEntry *ent)
nsHttpConnection *conn = nsnull;
for (i=0; i<count; ++i) {
trans = ent->mPendingQ[i];
GetConnection(ent, trans, &conn);
// 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.
PRBool alreadyHalfOpen = PR_FALSE;
for (PRInt32 j = 0; j < ((PRInt32) ent->mHalfOpens.Length()); j++) {
if (ent->mHalfOpens[j]->Transaction() == trans) {
alreadyHalfOpen = PR_TRUE;
break;
}
}
GetConnection(ent, trans, alreadyHalfOpen, &conn);
if (conn)
break;
}
@ -647,6 +661,7 @@ nsHttpConnectionMgr::AtActiveConnectionLimit(nsConnectionEntry *ent, PRUint8 cap
void
nsHttpConnectionMgr::GetConnection(nsConnectionEntry *ent,
nsHttpTransaction *trans,
PRBool onlyReusedConnection,
nsHttpConnection **result)
{
LOG(("nsHttpConnectionMgr::GetConnection [ci=%s caps=%x]\n",
@ -687,6 +702,12 @@ nsHttpConnectionMgr::GetConnection(nsConnectionEntry *ent,
}
if (!conn) {
// If the onlyReusedConnection parameter is TRUE, then GetConnection()
// does not create new transports under any circumstances.
if (onlyReusedConnection)
return;
// Check if we need to purge an idle connection. Note that we may have
// removed one above; if so, this will be a no-op. We do this before
// checking the active connection limit to catch the case where we do
@ -891,7 +912,7 @@ nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
trans->SetConnection(nsnull);
}
else
GetConnection(ent, trans, &conn);
GetConnection(ent, trans, PR_FALSE, &conn);
nsresult rv;
if (!conn) {

View File

@ -212,6 +212,8 @@ private:
void SetupBackupTimer();
void Abandon();
nsHttpTransaction *Transaction() { return mTransaction; }
private:
nsConnectionEntry *mEnt;
nsRefPtr<nsHttpTransaction> mTransaction;
@ -258,7 +260,7 @@ private:
PRBool ProcessPendingQForEntry(nsConnectionEntry *);
PRBool AtActiveConnectionLimit(nsConnectionEntry *, PRUint8 caps);
void GetConnection(nsConnectionEntry *, nsHttpTransaction *,
nsHttpConnection **);
PRBool, nsHttpConnection **);
nsresult DispatchTransaction(nsConnectionEntry *, nsAHttpTransaction *,
PRUint8 caps, nsHttpConnection *);
PRBool BuildPipeline(nsConnectionEntry *, nsAHttpTransaction *, nsHttpPipeline **);