зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1554411 - Make sure to deregister each HTTP/2 tunnel with the same key as used for its registration, r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D40406 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
31ac644a83
Коммит
1d2e827962
|
@ -4149,33 +4149,36 @@ void Http2Session::ConnectSlowConsumer(Http2Stream* stream) {
|
|||
}
|
||||
|
||||
uint32_t Http2Session::FindTunnelCount(nsHttpConnectionInfo* aConnInfo) {
|
||||
return FindTunnelCount(aConnInfo->HashKey());
|
||||
}
|
||||
uint32_t Http2Session::FindTunnelCount(nsCString const& aHashKey) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
uint32_t rv = 0;
|
||||
mTunnelHash.Get(aConnInfo->HashKey(), &rv);
|
||||
mTunnelHash.Get(aHashKey, &rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void Http2Session::RegisterTunnel(Http2Stream* aTunnel) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
nsHttpConnectionInfo* ci = aTunnel->Transaction()->ConnectionInfo();
|
||||
uint32_t newcount = FindTunnelCount(ci) + 1;
|
||||
mTunnelHash.Remove(ci->HashKey());
|
||||
mTunnelHash.Put(ci->HashKey(), newcount);
|
||||
nsCString const& regKey = aTunnel->RegistrationKey();
|
||||
uint32_t newcount = FindTunnelCount(regKey) + 1;
|
||||
mTunnelHash.Remove(regKey);
|
||||
mTunnelHash.Put(regKey, newcount);
|
||||
LOG3(("Http2Stream::RegisterTunnel %p stream=%p tunnels=%d [%s]", this,
|
||||
aTunnel, newcount, ci->HashKey().get()));
|
||||
aTunnel, newcount, regKey.get()));
|
||||
}
|
||||
|
||||
void Http2Session::UnRegisterTunnel(Http2Stream* aTunnel) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
nsHttpConnectionInfo* ci = aTunnel->Transaction()->ConnectionInfo();
|
||||
MOZ_ASSERT(FindTunnelCount(ci));
|
||||
uint32_t newcount = FindTunnelCount(ci) - 1;
|
||||
mTunnelHash.Remove(ci->HashKey());
|
||||
nsCString const& regKey = aTunnel->RegistrationKey();
|
||||
MOZ_ASSERT(FindTunnelCount(regKey));
|
||||
uint32_t newcount = FindTunnelCount(regKey) - 1;
|
||||
mTunnelHash.Remove(regKey);
|
||||
if (newcount) {
|
||||
mTunnelHash.Put(ci->HashKey(), newcount);
|
||||
mTunnelHash.Put(regKey, newcount);
|
||||
}
|
||||
LOG3(("Http2Session::UnRegisterTunnel %p stream=%p tunnels=%d [%s]", this,
|
||||
aTunnel, newcount, ci->HashKey().get()));
|
||||
aTunnel, newcount, regKey.get()));
|
||||
}
|
||||
|
||||
void Http2Session::CreateTunnel(nsHttpTransaction* trans,
|
||||
|
|
|
@ -596,6 +596,7 @@ class Http2Session final : public ASpdySession,
|
|||
void RegisterTunnel(Http2Stream*);
|
||||
void UnRegisterTunnel(Http2Stream*);
|
||||
uint32_t FindTunnelCount(nsHttpConnectionInfo*);
|
||||
uint32_t FindTunnelCount(nsCString const&);
|
||||
nsDataHashtable<nsCStringHashKey, uint32_t> mTunnelHash;
|
||||
uint32_t mTrrStreams;
|
||||
|
||||
|
|
|
@ -1592,6 +1592,17 @@ nsresult Http2Stream::OnWriteSegment(char* buf, uint32_t count,
|
|||
|
||||
/// connect tunnels
|
||||
|
||||
nsCString& Http2Stream::RegistrationKey() {
|
||||
if (mRegistrationKey.IsEmpty()) {
|
||||
MOZ_ASSERT(Transaction());
|
||||
MOZ_ASSERT(Transaction()->ConnectionInfo());
|
||||
|
||||
mRegistrationKey = Transaction()->ConnectionInfo()->HashKey();
|
||||
}
|
||||
|
||||
return mRegistrationKey;
|
||||
}
|
||||
|
||||
void Http2Stream::ClearTransactionsBlockedOnTunnel() {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
|
||||
|
|
|
@ -365,6 +365,11 @@ class Http2Stream : public nsAHttpSegmentReader,
|
|||
/// connect tunnels
|
||||
public:
|
||||
bool IsTunnel() { return mIsTunnel; }
|
||||
// TODO - remove as part of bug 1564120 fix?
|
||||
// This method saves the key the tunnel was registered under, so that when the
|
||||
// associated transaction connection info hash key changes, we still find it
|
||||
// and decrement the correct item in the session's tunnel hash table.
|
||||
nsCString& RegistrationKey();
|
||||
|
||||
private:
|
||||
void ClearTransactionsBlockedOnTunnel();
|
||||
|
@ -373,6 +378,7 @@ class Http2Stream : public nsAHttpSegmentReader,
|
|||
|
||||
bool mIsTunnel;
|
||||
bool mPlainTextTunnel;
|
||||
nsCString mRegistrationKey;
|
||||
|
||||
/// websockets
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче