зеркало из https://github.com/mozilla/pjs.git
Bug 684893 - part1: Start backup TCP SYN timer on primary TCP connection start, r=mcmanus
This commit is contained in:
Родитель
c6223b7102
Коммит
34dc4ec732
|
@ -844,7 +844,6 @@ nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent,
|
|||
nsresult rv = sock->SetupPrimaryStreams();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
sock->SetupBackupTimer();
|
||||
ent->mHalfOpens.AppendElement(sock);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1467,11 +1466,26 @@ nsHttpConnectionMgr::nsHalfOpenSocket::SetupBackupTimer()
|
|||
// so don't return an error in that case.
|
||||
nsresult rv;
|
||||
mSynTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mSynTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
|
||||
LOG(("nsHalfOpenSocket::SetupBackupTimer()"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionMgr::nsHalfOpenSocket::CancelBackupTimer()
|
||||
{
|
||||
// If the syntimer is still armed, we can cancel it because no backup
|
||||
// socket should be formed at this point
|
||||
if (!mSynTimer)
|
||||
return;
|
||||
|
||||
LOG(("nsHalfOpenSocket::CancelBackupTimer()"));
|
||||
mSynTimer->Cancel();
|
||||
mSynTimer = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionMgr::nsHalfOpenSocket::Abandon()
|
||||
{
|
||||
|
@ -1489,10 +1503,8 @@ nsHttpConnectionMgr::nsHalfOpenSocket::Abandon()
|
|||
mBackupStreamOut->AsyncWait(nsnull, 0, 0, nsnull);
|
||||
mBackupStreamOut = nsnull;
|
||||
}
|
||||
if (mSynTimer) {
|
||||
mSynTimer->Cancel();
|
||||
mSynTimer = nsnull;
|
||||
}
|
||||
|
||||
CancelBackupTimer();
|
||||
|
||||
mEnt = nsnull;
|
||||
}
|
||||
|
@ -1503,11 +1515,12 @@ nsHttpConnectionMgr::nsHalfOpenSocket::Notify(nsITimer *timer)
|
|||
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
NS_ABORT_IF_FALSE(timer == mSynTimer, "wrong timer");
|
||||
|
||||
mSynTimer = nsnull;
|
||||
if (!gHttpHandler->ConnMgr()->
|
||||
AtActiveConnectionLimit(mEnt, mTransaction->Caps())) {
|
||||
SetupBackupStreams();
|
||||
}
|
||||
|
||||
mSynTimer = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1527,15 +1540,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
|
|||
|
||||
gHttpHandler->ConnMgr()->RecvdConnect();
|
||||
|
||||
// If the syntimer is still armed, we can cancel it because no backup
|
||||
// socket should be formed at this point
|
||||
if (mSynTimer) {
|
||||
NS_ABORT_IF_FALSE (out == mStreamOut, "timer for non existant stream");
|
||||
LOG(("nsHalfOpenSocket::OnOutputStreamReady "
|
||||
"Backup connection timer canceled\n"));
|
||||
mSynTimer->Cancel();
|
||||
mSynTimer = nsnull;
|
||||
}
|
||||
CancelBackupTimer();
|
||||
|
||||
// assign the new socket to the http connection
|
||||
nsRefPtr<nsHttpConnection> conn = new nsHttpConnection();
|
||||
|
@ -1614,7 +1619,29 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
|
|||
PRUint64 progressMax)
|
||||
{
|
||||
if (mTransaction)
|
||||
mTransaction->OnTransportStatus(trans, status, progress);
|
||||
mTransaction->OnTransportStatus(trans, status, progress);
|
||||
|
||||
if (trans != mSocketTransport)
|
||||
return NS_OK;
|
||||
|
||||
switch (status) {
|
||||
case nsISocketTransport::STATUS_CONNECTING_TO:
|
||||
// Passed DNS resolution, now trying to connect, start the backup timer
|
||||
// only prevent creating another backup transport
|
||||
if (!mBackupTransport && !mSynTimer)
|
||||
SetupBackupTimer();
|
||||
break;
|
||||
|
||||
case nsISocketTransport::STATUS_CONNECTED_TO:
|
||||
// TCP connection's up, now transfer or SSL negotiantion starts,
|
||||
// no need for backup socket
|
||||
CancelBackupTimer();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,6 +220,7 @@ private:
|
|||
nsresult SetupPrimaryStreams();
|
||||
nsresult SetupBackupStreams();
|
||||
void SetupBackupTimer();
|
||||
void CancelBackupTimer();
|
||||
void Abandon();
|
||||
|
||||
nsHttpTransaction *Transaction() { return mTransaction; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче