зеркало из https://github.com/mozilla/gecko-dev.git
624739 - sort idle persistent http connections by pereceived server cwnd
--HG-- extra : rebase_source : 29c50d0c0e99220bb87b5f584188fad49cc33439
This commit is contained in:
Родитель
a3b0c12c5f
Коммит
c742414ab8
|
@ -70,6 +70,8 @@ nsHttpConnection::nsHttpConnection()
|
||||||
, mIdleTimeout(0)
|
, mIdleTimeout(0)
|
||||||
, mConsiderReusedAfterInterval(0)
|
, mConsiderReusedAfterInterval(0)
|
||||||
, mConsiderReusedAfterEpoch(0)
|
, mConsiderReusedAfterEpoch(0)
|
||||||
|
, mCurrentBytesRead(0)
|
||||||
|
, mMaxBytesRead(0)
|
||||||
, mKeepAlive(PR_TRUE) // assume to keep-alive by default
|
, mKeepAlive(PR_TRUE) // assume to keep-alive by default
|
||||||
, mKeepAliveMask(PR_TRUE)
|
, mKeepAliveMask(PR_TRUE)
|
||||||
, mSupportsPipelining(PR_FALSE) // assume low-grade server
|
, mSupportsPipelining(PR_FALSE) // assume low-grade server
|
||||||
|
@ -161,6 +163,9 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps)
|
||||||
goto failed_activation;
|
goto failed_activation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the per activation counter
|
||||||
|
mCurrentBytesRead = 0;
|
||||||
|
|
||||||
rv = OnOutputStreamReady(mSocketOut);
|
rv = OnOutputStreamReady(mSocketOut);
|
||||||
|
|
||||||
failed_activation:
|
failed_activation:
|
||||||
|
@ -502,6 +507,9 @@ nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason)
|
||||||
NS_ASSERTION(trans == mTransaction, "wrong transaction");
|
NS_ASSERTION(trans == mTransaction, "wrong transaction");
|
||||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||||
|
|
||||||
|
if (mCurrentBytesRead > mMaxBytesRead)
|
||||||
|
mMaxBytesRead = mCurrentBytesRead;
|
||||||
|
|
||||||
// mask this error code because its not a real error.
|
// mask this error code because its not a real error.
|
||||||
if (reason == NS_BASE_STREAM_CLOSED)
|
if (reason == NS_BASE_STREAM_CLOSED)
|
||||||
reason = NS_OK;
|
reason = NS_OK;
|
||||||
|
@ -677,13 +685,16 @@ nsHttpConnection::OnSocketReadable()
|
||||||
rv = NS_OK;
|
rv = NS_OK;
|
||||||
again = PR_FALSE;
|
again = PR_FALSE;
|
||||||
}
|
}
|
||||||
else if (NS_FAILED(mSocketInCondition)) {
|
else {
|
||||||
// continue waiting for the socket if necessary...
|
mCurrentBytesRead += n;
|
||||||
if (mSocketInCondition == NS_BASE_STREAM_WOULD_BLOCK)
|
if (NS_FAILED(mSocketInCondition)) {
|
||||||
rv = mSocketIn->AsyncWait(this, 0, 0, nsnull);
|
// continue waiting for the socket if necessary...
|
||||||
else
|
if (mSocketInCondition == NS_BASE_STREAM_WOULD_BLOCK)
|
||||||
rv = mSocketInCondition;
|
rv = mSocketIn->AsyncWait(this, 0, 0, nsnull);
|
||||||
again = PR_FALSE;
|
else
|
||||||
|
rv = mSocketInCondition;
|
||||||
|
again = PR_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// read more from the socket until error...
|
// read more from the socket until error...
|
||||||
} while (again);
|
} while (again);
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
nsresult PushBack(const char *data, PRUint32 length) { NS_NOTREACHED("PushBack"); return NS_ERROR_UNEXPECTED; }
|
nsresult PushBack(const char *data, PRUint32 length) { NS_NOTREACHED("PushBack"); return NS_ERROR_UNEXPECTED; }
|
||||||
nsresult ResumeSend();
|
nsresult ResumeSend();
|
||||||
nsresult ResumeRecv();
|
nsresult ResumeRecv();
|
||||||
|
PRInt64 MaxBytesRead() {return mMaxBytesRead;}
|
||||||
|
|
||||||
static NS_METHOD ReadFromStream(nsIInputStream *, void *, const char *,
|
static NS_METHOD ReadFromStream(nsIInputStream *, void *, const char *,
|
||||||
PRUint32, PRUint32, PRUint32 *);
|
PRUint32, PRUint32, PRUint32 *);
|
||||||
|
@ -180,6 +181,8 @@ private:
|
||||||
PRUint16 mIdleTimeout; // value of keep-alive: timeout=
|
PRUint16 mIdleTimeout; // value of keep-alive: timeout=
|
||||||
PRIntervalTime mConsiderReusedAfterInterval;
|
PRIntervalTime mConsiderReusedAfterInterval;
|
||||||
PRIntervalTime mConsiderReusedAfterEpoch;
|
PRIntervalTime mConsiderReusedAfterEpoch;
|
||||||
|
PRInt64 mCurrentBytesRead; // data read per activation
|
||||||
|
PRInt64 mMaxBytesRead; // max read in 1 activation
|
||||||
|
|
||||||
PRPackedBool mKeepAlive;
|
PRPackedBool mKeepAlive;
|
||||||
PRPackedBool mKeepAliveMask;
|
PRPackedBool mKeepAliveMask;
|
||||||
|
|
|
@ -1057,12 +1057,24 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(PRInt32, void *param)
|
||||||
|
|
||||||
if (conn->CanReuse()) {
|
if (conn->CanReuse()) {
|
||||||
LOG((" adding connection to idle list\n"));
|
LOG((" adding connection to idle list\n"));
|
||||||
// hold onto this connection in the idle list. we push it to
|
// Keep The idle connection list sorted with the connections that
|
||||||
// the end of the list so as to ensure that we'll visit older
|
// have moved the largest data pipelines at the front because these
|
||||||
// connections first before getting to this one.
|
// connections have the largest cwnds on the server.
|
||||||
|
|
||||||
|
// The linear search is ok here because the number of idleconns
|
||||||
|
// in a single entry is generally limited to a small number (i.e. 6)
|
||||||
|
|
||||||
|
PRInt32 idx;
|
||||||
|
for (idx = 0; idx < ent->mIdleConns.Length(); idx++) {
|
||||||
|
nsHttpConnection *idleConn = ent->mIdleConns[idx];
|
||||||
|
if (idleConn->MaxBytesRead() < conn->MaxBytesRead())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
NS_ADDREF(conn);
|
NS_ADDREF(conn);
|
||||||
ent->mIdleConns.AppendElement(conn);
|
ent->mIdleConns.InsertElementAt(idx, conn);
|
||||||
mNumIdleConns++;
|
mNumIdleConns++;
|
||||||
|
|
||||||
// If the added connection was first idle connection or has shortest
|
// If the added connection was first idle connection or has shortest
|
||||||
// time to live among the idle connections, pruning dead
|
// time to live among the idle connections, pruning dead
|
||||||
// connections needs to be done when it can't be reused anymore.
|
// connections needs to be done when it can't be reused anymore.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче