Bug 1958224 - Use nsTArray to store tunnel streams, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D244325
This commit is contained in:
@@ -203,7 +203,7 @@ void Http2Session::Shutdown(nsresult aReason) {
|
|||||||
ShutdownStream(stream, aReason);
|
ShutdownStream(stream, aReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& stream : mTunnelStreamTransactionHash.Values()) {
|
for (auto& stream : mTunnelStreams) {
|
||||||
ShutdownStream(stream, aReason);
|
ShutdownStream(stream, aReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,8 +591,8 @@ already_AddRefed<nsHttpConnection> Http2Session::CreateTunnelStream(
|
|||||||
RefPtr<nsHttpConnection> newConn = refStream->CreateHttpConnection(
|
RefPtr<nsHttpConnection> newConn = refStream->CreateHttpConnection(
|
||||||
aHttpTransaction, aCallbacks, aRtt, aIsExtendedCONNECT);
|
aHttpTransaction, aCallbacks, aRtt, aIsExtendedCONNECT);
|
||||||
|
|
||||||
mTunnelStreamTransactionHash.InsertOrUpdate(aHttpTransaction,
|
refStream->SetTransactionId(reinterpret_cast<uintptr_t>(aHttpTransaction));
|
||||||
std::move(refStream));
|
mTunnelStreams.AppendElement(std::move(refStream));
|
||||||
return newConn.forget();
|
return newConn.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1316,7 +1316,7 @@ void Http2Session::CleanupStream(Http2StreamBase* aStream, nsresult aResult,
|
|||||||
// its transaction
|
// its transaction
|
||||||
nsAHttpTransaction* trans = aStream->Transaction();
|
nsAHttpTransaction* trans = aStream->Transaction();
|
||||||
mStreamTransactionHash.Remove(trans);
|
mStreamTransactionHash.Remove(trans);
|
||||||
mTunnelStreamTransactionHash.Remove(trans);
|
mTunnelStreams.RemoveElement(aStream);
|
||||||
|
|
||||||
if (mShouldGoAway && !mStreamTransactionHash.Count()) Close(NS_OK);
|
if (mShouldGoAway && !mStreamTransactionHash.Count()) Close(NS_OK);
|
||||||
}
|
}
|
||||||
@@ -3402,7 +3402,7 @@ void Http2Session::Close(nsresult aReason) {
|
|||||||
|
|
||||||
mStreamIDHash.Clear();
|
mStreamIDHash.Clear();
|
||||||
mStreamTransactionHash.Clear();
|
mStreamTransactionHash.Clear();
|
||||||
mTunnelStreamTransactionHash.Clear();
|
mTunnelStreams.Clear();
|
||||||
|
|
||||||
uint32_t goAwayReason;
|
uint32_t goAwayReason;
|
||||||
if (mGoAwayReason != NO_HTTP_ERROR) {
|
if (mGoAwayReason != NO_HTTP_ERROR) {
|
||||||
@@ -3875,8 +3875,15 @@ nsresult Http2Session::TakeTransport(nsISocketTransport**,
|
|||||||
|
|
||||||
WebTransportSessionBase* Http2Session::GetWebTransportSession(
|
WebTransportSessionBase* Http2Session::GetWebTransportSession(
|
||||||
nsAHttpTransaction* aTransaction) {
|
nsAHttpTransaction* aTransaction) {
|
||||||
RefPtr<Http2StreamBase> stream =
|
uintptr_t id = reinterpret_cast<uintptr_t>(aTransaction);
|
||||||
mTunnelStreamTransactionHash.Get(aTransaction);
|
RefPtr<Http2StreamBase> stream;
|
||||||
|
for (auto& entry : mTunnelStreams) {
|
||||||
|
if (entry->GetTransactionId() == id) {
|
||||||
|
entry->SetTransactionId(0);
|
||||||
|
stream = entry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!stream || !stream->GetHttp2WebTransportSession()) {
|
if (!stream || !stream->GetHttp2WebTransportSession()) {
|
||||||
MOZ_ASSERT(false, "There must be a stream");
|
MOZ_ASSERT(false, "There must be a stream");
|
||||||
|
|||||||
@@ -417,8 +417,7 @@ class Http2Session final : public ASpdySession,
|
|||||||
nsTHashMap<nsUint32HashKey, Http2StreamBase*> mStreamIDHash;
|
nsTHashMap<nsUint32HashKey, Http2StreamBase*> mStreamIDHash;
|
||||||
nsRefPtrHashtable<nsPtrHashKey<nsAHttpTransaction>, Http2StreamBase>
|
nsRefPtrHashtable<nsPtrHashKey<nsAHttpTransaction>, Http2StreamBase>
|
||||||
mStreamTransactionHash;
|
mStreamTransactionHash;
|
||||||
nsRefPtrHashtable<nsPtrHashKey<nsAHttpTransaction>, Http2StreamBase>
|
nsTArray<RefPtr<Http2StreamTunnel>> mTunnelStreams;
|
||||||
mTunnelStreamTransactionHash;
|
|
||||||
|
|
||||||
nsTArray<WeakPtr<Http2StreamBase>> mReadyForWrite;
|
nsTArray<WeakPtr<Http2StreamBase>> mReadyForWrite;
|
||||||
nsTArray<WeakPtr<Http2StreamBase>> mQueuedStreams;
|
nsTArray<WeakPtr<Http2StreamBase>> mQueuedStreams;
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class Http2StreamTunnel : public Http2StreamBase,
|
|||||||
}
|
}
|
||||||
void MakeNonSticky() override {}
|
void MakeNonSticky() override {}
|
||||||
|
|
||||||
|
void SetTransactionId(uintptr_t aId) { mId = aId; };
|
||||||
|
uintptr_t GetTransactionId() const { return mId; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~Http2StreamTunnel();
|
~Http2StreamTunnel();
|
||||||
nsresult CallToReadData(uint32_t count, uint32_t* countRead) override;
|
nsresult CallToReadData(uint32_t count, uint32_t* countRead) override;
|
||||||
@@ -72,6 +75,8 @@ class Http2StreamTunnel : public Http2StreamBase,
|
|||||||
RefPtr<nsHttpConnectionInfo> mConnectionInfo;
|
RefPtr<nsHttpConnectionInfo> mConnectionInfo;
|
||||||
bool mSendClosed{false};
|
bool mSendClosed{false};
|
||||||
nsresult mCondition{NS_OK};
|
nsresult mCondition{NS_OK};
|
||||||
|
// Stores the address of the transaction that created this Http2StreamTunnel.
|
||||||
|
uintptr_t mId{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
// f9d10060-f5d4-443e-ba59-f84ea975c5f0
|
// f9d10060-f5d4-443e-ba59-f84ea975c5f0
|
||||||
|
|||||||
Reference in New Issue
Block a user