From dd677444419bca44b50dbbec0e2ea1a9bfaf400a Mon Sep 17 00:00:00 2001 From: Cristian Tuns Date: Fri, 9 Feb 2024 16:32:14 -0500 Subject: [PATCH] Backed out changeset 3c97098ecdef (bug 1755186) for causing build bustages in Http2Compression.h CLOSED TREE --- netwerk/protocol/http/Http2Compression.cpp | 33 ++++++---------------- netwerk/protocol/http/Http2Compression.h | 9 ------ 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/netwerk/protocol/http/Http2Compression.cpp b/netwerk/protocol/http/Http2Compression.cpp index b95883f13f0e..4d16e9e53208 100644 --- a/netwerk/protocol/http/Http2Compression.cpp +++ b/netwerk/protocol/http/Http2Compression.cpp @@ -61,7 +61,6 @@ class HpackDynamicTableReporter final : public nsIMemoryReporter { NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - MutexAutoLock lock(mMutex); if (mCompressor) { MOZ_COLLECT_REPORT("explicit/network/hpack/dynamic-tables", KIND_HEAP, UNITS_BYTES, @@ -76,8 +75,7 @@ class HpackDynamicTableReporter final : public nsIMemoryReporter { ~HpackDynamicTableReporter() = default; - Mutex mMutex{"HpackDynamicTableReporter"}; - Http2BaseCompressor* mCompressor MOZ_GUARDED_BY(mMutex); + Http2BaseCompressor* mCompressor; friend class Http2BaseCompressor; }; @@ -189,18 +187,13 @@ nvFIFO::~nvFIFO() { Clear(); } void nvFIFO::AddElement(const nsCString& name, const nsCString& value) { nvPair* pair = new nvPair(name, value); mByteCount += pair->Size(); - MutexAutoLock lock(mMutex); mTable.PushFront(pair); } void nvFIFO::AddElement(const nsCString& name) { AddElement(name, ""_ns); } void nvFIFO::RemoveElement() { - nvPair* pair = nullptr; - { - MutexAutoLock lock(mMutex); - pair = mTable.Pop(); - } + nvPair* pair = mTable.Pop(); if (pair) { mByteCount -= pair->Size(); delete pair; @@ -219,7 +212,6 @@ size_t nvFIFO::StaticLength() const { return gStaticHeaders->GetSize(); } void nvFIFO::Clear() { mByteCount = 0; - MutexAutoLock lock(mMutex); while (mTable.GetSize()) { delete mTable.Pop(); } @@ -252,27 +244,20 @@ Http2BaseCompressor::~Http2BaseCompressor() { Telemetry::Accumulate(mPeakCountID, mPeakCount); } UnregisterStrongMemoryReporter(mDynamicReporter); - { - MutexAutoLock lock(mDynamicReporter->mMutex); - mDynamicReporter->mCompressor = nullptr; - } + mDynamicReporter->mCompressor = nullptr; mDynamicReporter = nullptr; } -size_t nvFIFO::SizeOfDynamicTable(mozilla::MallocSizeOf aMallocSizeOf) const { - size_t size = 0; - MutexAutoLock lock(mMutex); - for (const auto elem : mTable) { - size += elem->SizeOfIncludingThis(aMallocSizeOf); - } - return size; -} - void Http2BaseCompressor::ClearHeaderTable() { mHeaderTable.Clear(); } size_t Http2BaseCompressor::SizeOfExcludingThis( mozilla::MallocSizeOf aMallocSizeOf) const { - return mHeaderTable.SizeOfDynamicTable(aMallocSizeOf); + size_t size = 0; + for (uint32_t i = mHeaderTable.StaticLength(); i < mHeaderTable.Length(); + ++i) { + size += mHeaderTable[i]->SizeOfIncludingThis(aMallocSizeOf); + } + return size; } void Http2BaseCompressor::MakeRoom(uint32_t amount, const char* direction) { diff --git a/netwerk/protocol/http/Http2Compression.h b/netwerk/protocol/http/Http2Compression.h index a22639f132fa..dd985846072d 100644 --- a/netwerk/protocol/http/Http2Compression.h +++ b/netwerk/protocol/http/Http2Compression.h @@ -13,7 +13,6 @@ #include "nsDeque.h" #include "nsString.h" #include "mozilla/Telemetry.h" -#include "mozilla/Mutex.h" namespace mozilla { namespace net { @@ -48,18 +47,10 @@ class nvFIFO { size_t StaticLength() const; void Clear(); const nvPair* operator[](size_t index) const; - size_t SizeOfDynamicTable(mozilla::MallocSizeOf aMallocSizeOf) const; private: uint32_t mByteCount{0}; nsDeque mTable; - - // This mutex is held when adding or removing elements in the table - // and when accessing the table from the main thread (in SizeOfDynamicTable) - // Since the operator[] and other const methods are always called - // on the socket thread, they don't need to lock the mutex. - // Mutable so it can be locked in SizeOfDynamicTable which is const - mutable Mutex mMutex{"nvFIFO"} MOZ_UNANNOTATED; }; class HpackDynamicTableReporter;