зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364189 - Make sure not to retry socketTransaction if nsHttpConnectionMgr cancels it. r=mcmanus
This commit is contained in:
Родитель
7b90492a1f
Коммит
d88e097afa
|
@ -36,7 +36,7 @@ public:
|
|||
// Inform nsHalfopenSocket whether a connection using TFO succeeded or not.
|
||||
// This will cancel the backup connection and in case of a failure rewind
|
||||
// the transaction.
|
||||
virtual void SetFastOpenConnected(nsresult error) = 0;
|
||||
virtual void SetFastOpenConnected(nsresult error, bool aWillRetry) = 0;
|
||||
virtual void FastOpenNotSupported() = 0;
|
||||
virtual void SetFastOpenStatus(uint8_t tfoStatus) = 0;
|
||||
};
|
||||
|
|
|
@ -794,6 +794,7 @@ nsSocketTransport::nsSocketTransport()
|
|||
, mKeepaliveProbeCount(-1)
|
||||
, mFastOpenCallback(nullptr)
|
||||
, mFastOpenLayerHasBufferedData(false)
|
||||
, mDoNotRetryToConnect(false)
|
||||
{
|
||||
SOCKET_LOG(("creating nsSocketTransport @%p\n", this));
|
||||
|
||||
|
@ -1698,6 +1699,13 @@ nsSocketTransport::RecoverFromError()
|
|||
SOCKET_LOG(("nsSocketTransport::RecoverFromError [this=%p state=%x cond=%" PRIx32 "]\n",
|
||||
this, mState, static_cast<uint32_t>(mCondition)));
|
||||
|
||||
if (mDoNotRetryToConnect) {
|
||||
SOCKET_LOG(("nsSocketTransport::RecoverFromError do not retry because "
|
||||
"mDoNotRetryToConnect is set [this=%p]\n",
|
||||
this));
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
// Unix domain connections don't have multiple addresses to try,
|
||||
// so the recovery techniques here don't apply.
|
||||
|
@ -1745,7 +1753,7 @@ nsSocketTransport::RecoverFromError()
|
|||
// connected, mFDFastOpenInProgress will be true but mFastOpenCallback
|
||||
// will be nullptr.
|
||||
if (mFastOpenCallback) {
|
||||
mFastOpenCallback->SetFastOpenConnected(mCondition);
|
||||
mFastOpenCallback->SetFastOpenConnected(mCondition, true);
|
||||
}
|
||||
mFastOpenCallback = nullptr;
|
||||
} else {
|
||||
|
@ -1875,7 +1883,7 @@ nsSocketTransport::OnSocketConnected()
|
|||
// mFastOpenCallback can be null when for example h2 is negotiated on
|
||||
// another connection to the same host and all connections are
|
||||
// abandoned.
|
||||
mFastOpenCallback->SetFastOpenConnected(NS_OK);
|
||||
mFastOpenCallback->SetFastOpenConnected(NS_OK, false);
|
||||
}
|
||||
mFastOpenCallback = nullptr;
|
||||
|
||||
|
@ -2302,7 +2310,7 @@ nsSocketTransport::OnSocketDetached(PRFileDesc *fd)
|
|||
// connected, mFDFastOpenInProgress will be true but mFastOpenCallback
|
||||
// will be nullptr.
|
||||
if (mFDFastOpenInProgress && mFastOpenCallback) {
|
||||
mFastOpenCallback->SetFastOpenConnected(mCondition);
|
||||
mFastOpenCallback->SetFastOpenConnected(mCondition, false);
|
||||
}
|
||||
mFastOpenCallback = nullptr;
|
||||
|
||||
|
@ -2503,8 +2511,10 @@ nsSocketTransport::Close(nsresult reason)
|
|||
if (NS_SUCCEEDED(reason))
|
||||
reason = NS_BASE_STREAM_CLOSED;
|
||||
|
||||
mDoNotRetryToConnect = true;
|
||||
|
||||
if (mFDFastOpenInProgress && mFastOpenCallback) {
|
||||
mFastOpenCallback->SetFastOpenConnected(reason);
|
||||
mFastOpenCallback->SetFastOpenConnected(reason, false);
|
||||
}
|
||||
mFastOpenCallback = nullptr;
|
||||
|
||||
|
|
|
@ -477,6 +477,8 @@ private:
|
|||
// A Fast Open callback.
|
||||
TCPFastOpen *mFastOpenCallback;
|
||||
bool mFastOpenLayerHasBufferedData;
|
||||
|
||||
bool mDoNotRetryToConnect;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -3567,13 +3567,14 @@ nsHalfOpenSocket::StartFastOpen()
|
|||
|
||||
void
|
||||
nsHttpConnectionMgr::
|
||||
nsHalfOpenSocket::SetFastOpenConnected(nsresult aError)
|
||||
nsHalfOpenSocket::SetFastOpenConnected(nsresult aError, bool aWillRetry)
|
||||
{
|
||||
RefPtr<nsHalfOpenSocket> deleteProtector(this);
|
||||
|
||||
// Check if we want to restart connection!
|
||||
if ((aError == NS_ERROR_CONNECTION_REFUSED) ||
|
||||
(aError == NS_ERROR_NET_TIMEOUT)) {
|
||||
if (aWillRetry &&
|
||||
((aError == NS_ERROR_CONNECTION_REFUSED) ||
|
||||
(aError == NS_ERROR_NET_TIMEOUT))) {
|
||||
if (mEnt->mUseFastOpen) {
|
||||
gHttpHandler->IncrementFastOpenConsecutiveFailureCounter();
|
||||
mEnt->mUseFastOpen = false;
|
||||
|
|
|
@ -376,7 +376,7 @@ private:
|
|||
|
||||
bool FastOpenEnabled() override;
|
||||
nsresult StartFastOpen() override;
|
||||
void SetFastOpenConnected(nsresult) override;
|
||||
void SetFastOpenConnected(nsresult, bool aWillRetry) override;
|
||||
void FastOpenNotSupported() override;
|
||||
void SetFastOpenStatus(uint8_t tfoStatus) override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче