зеркало из https://github.com/mozilla/gecko-dev.git
bug 1094522 - claim conns with null transactions instead of starting new ones r=hurley
This commit is contained in:
Родитель
da32e99bda
Коммит
1d224b6824
|
@ -97,6 +97,7 @@ NullHttpTransaction::NullHttpTransaction(nsHttpConnectionInfo *ci,
|
|||
, mCapsToClear(0)
|
||||
, mRequestHead(nullptr)
|
||||
, mIsDone(false)
|
||||
, mClaimed(false)
|
||||
, mCallbacks(callbacks)
|
||||
, mConnectionInfo(ci)
|
||||
{
|
||||
|
@ -126,6 +127,16 @@ NullHttpTransaction::~NullHttpTransaction()
|
|||
delete mRequestHead;
|
||||
}
|
||||
|
||||
bool
|
||||
NullHttpTransaction::Claim()
|
||||
{
|
||||
if (mClaimed) {
|
||||
return false;
|
||||
}
|
||||
mClaimed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
NullHttpTransaction::SetConnection(nsAHttpConnection *conn)
|
||||
{
|
||||
|
|
|
@ -38,8 +38,11 @@ public:
|
|||
nsIInterfaceRequestor *callbacks,
|
||||
uint32_t caps);
|
||||
|
||||
bool Claim();
|
||||
|
||||
// Overload of nsAHttpTransaction methods
|
||||
bool IsNullTransaction() MOZ_OVERRIDE MOZ_FINAL { return true; }
|
||||
NullHttpTransaction *QueryNullTransaction() MOZ_OVERRIDE MOZ_FINAL { return this; }
|
||||
bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL {return true; }
|
||||
PRIntervalTime ResponseTimeout() MOZ_OVERRIDE MOZ_FINAL
|
||||
{
|
||||
|
@ -62,6 +65,7 @@ private:
|
|||
uint32_t mCapsToClear;
|
||||
nsHttpRequestHead *mRequestHead;
|
||||
bool mIsDone;
|
||||
bool mClaimed;
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsAHttpConnection> mConnection;
|
||||
|
|
|
@ -750,6 +750,15 @@ TLSFilterTransaction::IsNullTransaction()
|
|||
return mTransaction->IsNullTransaction();
|
||||
}
|
||||
|
||||
NullHttpTransaction *
|
||||
TLSFilterTransaction::QueryNullTransaction()
|
||||
{
|
||||
if (!mTransaction) {
|
||||
return nullptr;
|
||||
}
|
||||
return mTransaction->QueryNullTransaction();
|
||||
}
|
||||
|
||||
nsHttpTransaction *
|
||||
TLSFilterTransaction::QueryHttpTransaction()
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ struct PRSocketOptionData;
|
|||
namespace mozilla { namespace net {
|
||||
|
||||
class nsHttpRequestHead;
|
||||
class NullHttpTransaction;
|
||||
class TLSFilterTransaction;
|
||||
|
||||
class NudgeTunnelCallback : public nsISupports
|
||||
|
@ -127,6 +128,7 @@ public:
|
|||
// nsAHttpTransaction overloads
|
||||
nsHttpPipeline *QueryPipeline() MOZ_OVERRIDE;
|
||||
bool IsNullTransaction() MOZ_OVERRIDE;
|
||||
NullHttpTransaction *QueryNullTransaction() MOZ_OVERRIDE;
|
||||
nsHttpTransaction *QueryHttpTransaction() MOZ_OVERRIDE;
|
||||
SpdyConnectTransaction *QuerySpdyConnectTransaction() MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class nsHttpTransaction;
|
|||
class nsHttpPipeline;
|
||||
class nsHttpRequestHead;
|
||||
class nsHttpConnectionInfo;
|
||||
class NullHttpTransaction;
|
||||
class SpdyConnectTransaction;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -119,7 +120,7 @@ public:
|
|||
|
||||
// Occasionally the abstract interface has to give way to base implementations
|
||||
// to respect differences between spdy, pipelines, etc..
|
||||
// These Query* (and IsNUllTransaction()) functions provide a way to do
|
||||
// These Query* (and IsNullTransaction()) functions provide a way to do
|
||||
// that without using xpcom or rtti. Any calling code that can't deal with
|
||||
// a null response from one of them probably shouldn't be using nsAHttpTransaction
|
||||
|
||||
|
@ -132,6 +133,7 @@ public:
|
|||
// A null transaction is expected to return BASE_STREAM_CLOSED on all of
|
||||
// its IO functions all the time.
|
||||
virtual bool IsNullTransaction() { return false; }
|
||||
virtual NullHttpTransaction *QueryNullTransaction() { return nullptr; }
|
||||
|
||||
// If we used rtti this would be the result of doing
|
||||
// dynamic_cast<nsHttpTransaction *>(this).. i.e. it can be nullptr for
|
||||
|
|
|
@ -1500,6 +1500,18 @@ nsHttpConnectionMgr::MakeNewConnection(nsConnectionEntry *ent,
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t activeLength = ent->mActiveConns.Length();
|
||||
for (uint32_t i = 0; i < activeLength; i++) {
|
||||
nsAHttpTransaction *activeTrans = ent->mActiveConns[i]->Transaction();
|
||||
NullHttpTransaction *nullTrans = activeTrans ? activeTrans->QueryNullTransaction() : nullptr;
|
||||
if (nullTrans && nullTrans->Claim()) {
|
||||
LOG(("nsHttpConnectionMgr::MakeNewConnection [ci = %s] "
|
||||
"Claiming a null transaction for later use\n",
|
||||
ent->mConnInfo->HashKey().get()));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If this host is trying to negotiate a SPDY session right now,
|
||||
// don't create any new connections until the result of the
|
||||
// negotiation is known.
|
||||
|
|
Загрузка…
Ссылка в новой задаче