Bug 1347963 - part 3 - make nsHttpResponseHead use RecursiveMutex; r=mcmanus
authorNathan Froyd <froydnj@mozilla.com>
Tue, 18 Apr 2017 12:00:58 -0400
changeset 420022 a9be4c2f9c2a8e4451e710879bd640fc685af09b
parent 420021 7232578cc2b11d4348fb6bfa928005c4b264974b
child 420023 b9bd9b93f78693726cdb7ccfa7364c1e40c93f49
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1347963
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1347963 - part 3 - make nsHttpResponseHead use RecursiveMutex; r=mcmanus Making nsHttpResponseHead slightly faster with RecursiveMutex is a good thing.
netwerk/protocol/http/nsHttpResponseHead.cpp
netwerk/protocol/http/nsHttpResponseHead.h
--- a/netwerk/protocol/http/nsHttpResponseHead.cpp
+++ b/netwerk/protocol/http/nsHttpResponseHead.cpp
@@ -19,21 +19,21 @@
 namespace mozilla {
 namespace net {
 
 //-----------------------------------------------------------------------------
 // nsHttpResponseHead <public>
 //-----------------------------------------------------------------------------
 
 nsHttpResponseHead::nsHttpResponseHead(const nsHttpResponseHead &aOther)
-    : mReentrantMonitor("nsHttpResponseHead.mReentrantMonitor")
+    : mRecursiveMutex("nsHttpResponseHead.mRecursiveMutex")
     , mInVisitHeaders(false)
 {
     nsHttpResponseHead &other = const_cast<nsHttpResponseHead&>(aOther);
-    ReentrantMonitorAutoEnter monitor(other.mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(other.mRecursiveMutex);
 
     mHeaders = other.mHeaders;
     mVersion = other.mVersion;
     mStatus = other.mStatus;
     mStatusText = other.mStatusText;
     mContentLength = other.mContentLength;
     mContentType = other.mContentType;
     mContentCharset = other.mContentCharset;
@@ -43,18 +43,18 @@ nsHttpResponseHead::nsHttpResponseHead(c
     mCacheControlImmutable = other.mCacheControlImmutable;
     mPragmaNoCache = other.mPragmaNoCache;
 }
 
 nsHttpResponseHead&
 nsHttpResponseHead::operator=(const nsHttpResponseHead &aOther)
 {
     nsHttpResponseHead &other = const_cast<nsHttpResponseHead&>(aOther);
-    ReentrantMonitorAutoEnter monitorOther(other.mReentrantMonitor);
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitorOther(other.mRecursiveMutex);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
     mHeaders = other.mHeaders;
     mVersion = other.mVersion;
     mStatus = other.mStatus;
     mStatusText = other.mStatusText;
     mContentLength = other.mContentLength;
     mContentType = other.mContentType;
     mContentCharset = other.mContentCharset;
@@ -65,89 +65,89 @@ nsHttpResponseHead::operator=(const nsHt
     mPragmaNoCache = other.mPragmaNoCache;
 
     return *this;
 }
 
 nsHttpVersion
 nsHttpResponseHead::Version()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mVersion;
 }
 
 uint16_t
 nsHttpResponseHead::Status()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mStatus;
 }
 
 void
 nsHttpResponseHead::StatusText(nsACString &aStatusText)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     aStatusText = mStatusText;
 }
 
 int64_t
 nsHttpResponseHead::ContentLength()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mContentLength;
 }
 
 void
 nsHttpResponseHead::ContentType(nsACString &aContentType)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     aContentType = mContentType;
 }
 
 void
 nsHttpResponseHead::ContentCharset(nsACString &aContentCharset)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     aContentCharset = mContentCharset;
 }
 
 bool
 nsHttpResponseHead::Private()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mCacheControlPrivate;
 }
 
 bool
 nsHttpResponseHead::NoStore()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mCacheControlNoStore;
 }
 
 bool
 nsHttpResponseHead::NoCache()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return (mCacheControlNoCache || mPragmaNoCache);
 }
 
 bool
 nsHttpResponseHead::Immutable()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mCacheControlImmutable;
 }
 
 nsresult
 nsHttpResponseHead::SetHeader(const nsACString &hdr,
                               const nsACString &val,
                               bool merge)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
     if (mInVisitHeaders) {
         return NS_ERROR_FAILURE;
     }
 
     nsHttpAtom atom = nsHttp::ResolveAtom(PromiseFlatCString(hdr).get());
     if (!atom) {
         NS_WARNING("failed to resolve atom");
@@ -157,17 +157,17 @@ nsHttpResponseHead::SetHeader(const nsAC
     return SetHeader_locked(atom, hdr, val, merge);
 }
 
 nsresult
 nsHttpResponseHead::SetHeader(nsHttpAtom hdr,
                               const nsACString &val,
                               bool merge)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
     if (mInVisitHeaders) {
         return NS_ERROR_FAILURE;
     }
 
     return SetHeader_locked(hdr, EmptyCString(), val, merge);
 }
 
@@ -190,66 +190,66 @@ nsHttpResponseHead::SetHeader_locked(nsH
 
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::GetHeader(nsHttpAtom h, nsACString &v)
 {
     v.Truncate();
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mHeaders.GetHeader(h, v);
 }
 
 void
 nsHttpResponseHead::ClearHeader(nsHttpAtom h)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mHeaders.ClearHeader(h);
 }
 
 void
 nsHttpResponseHead::ClearHeaders()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mHeaders.Clear();
 }
 
 bool
 nsHttpResponseHead::HasHeaderValue(nsHttpAtom h, const char *v)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mHeaders.HasHeaderValue(h, v);
 }
 
 bool
 nsHttpResponseHead::HasHeader(nsHttpAtom h)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return mHeaders.HasHeader(h);
 }
 
 void
 nsHttpResponseHead::SetContentType(const nsACString &s)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mContentType = s;
 }
 
 void
 nsHttpResponseHead::SetContentCharset(const nsACString &s)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mContentCharset = s;
 }
 
 void
 nsHttpResponseHead::SetContentLength(int64_t len)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
     mContentLength = len;
     if (len < 0)
         mHeaders.ClearHeader(nsHttp::Content_Length);
     else {
         DebugOnly<nsresult> rv =
             mHeaders.SetHeader(nsHttp::Content_Length,
                                nsPrintfCString("%" PRId64, len),
@@ -257,17 +257,17 @@ nsHttpResponseHead::SetContentLength(int
                                nsHttpHeaderArray::eVarietyResponse);
         MOZ_ASSERT(NS_SUCCEEDED(rv));
     }
 }
 
 void
 nsHttpResponseHead::Flatten(nsACString &buf, bool pruneTransients)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     if (mVersion == NS_HTTP_VERSION_0_9)
         return;
 
     buf.AppendLiteral("HTTP/");
     if (mVersion == NS_HTTP_VERSION_2_0)
         buf.AppendLiteral("2.0 ");
     else if (mVersion == NS_HTTP_VERSION_1_1)
         buf.AppendLiteral("1.1 ");
@@ -281,28 +281,28 @@ nsHttpResponseHead::Flatten(nsACString &
 
 
     mHeaders.Flatten(buf, false, pruneTransients);
 }
 
 void
 nsHttpResponseHead::FlattenNetworkOriginalHeaders(nsACString &buf)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     if (mVersion == NS_HTTP_VERSION_0_9) {
         return;
     }
 
     mHeaders.FlattenOriginalHeader(buf);
 }
 
 nsresult
 nsHttpResponseHead::ParseCachedHead(const char *block)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     LOG(("nsHttpResponseHead::ParseCachedHead [this=%p]\n", this));
 
     // this command works on a buffer as prepared by Flatten, as such it is
     // not very forgiving ;-)
 
     char *p = PL_strstr(block, "\r\n");
     if (!p)
         return NS_ERROR_UNEXPECTED;
@@ -324,17 +324,17 @@ nsHttpResponseHead::ParseCachedHead(cons
     } while (1);
 
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::ParseCachedOriginalHeaders(char *block)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     LOG(("nsHttpResponseHead::ParseCachedOriginalHeader [this=%p]\n", this));
 
     // this command works on a buffer as prepared by FlattenOriginalHeader,
     // as such it is not very forgiving ;-)
 
     if (!block) {
         return NS_ERROR_UNEXPECTED;
     }
@@ -530,17 +530,17 @@ nsHttpResponseHead::AssignDefaultStatusT
         break;
     }
 }
 
 void
 nsHttpResponseHead::ParseStatusLine(const nsACString &line)
 {
 
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     ParseStatusLine_locked(line);
 }
 
 void
 nsHttpResponseHead::ParseStatusLine_locked(const nsACString &line)
 {
     //
     // Parse Status-Line:: HTTP-Version SP Status-Code SP Reason-Phrase CRLF
@@ -581,17 +581,17 @@ nsHttpResponseHead::ParseStatusLine_lock
 
     LOG(("Have status line [version=%u status=%u statusText=%s]\n",
         unsigned(mVersion), unsigned(mStatus), mStatusText.get()));
 }
 
 nsresult
 nsHttpResponseHead::ParseHeaderLine(const nsACString &line)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return ParseHeaderLine_locked(line, true);
 }
 
 nsresult
 nsHttpResponseHead::ParseHeaderLine_locked(const nsACString &line, bool originalFromNetHeaders)
 {
     nsHttpAtom hdr = {0};
     nsAutoCString headerNameOriginal;
@@ -654,17 +654,17 @@ nsHttpResponseHead::ParseHeaderLine_lock
 //
 // This is typically a very small number.
 //
 nsresult
 nsHttpResponseHead::ComputeCurrentAge(uint32_t now,
                                       uint32_t requestTime,
                                       uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     uint32_t dateValue;
     uint32_t ageValue;
 
     *result = 0;
 
     if (requestTime > now) {
         // for calculation purposes lets not allow the request to happen in the future
         requestTime = now;
@@ -700,17 +700,17 @@ nsHttpResponseHead::ComputeCurrentAge(ui
 // <or>
 //     freshnessLifetime = min(one-week,(date_value - last_modified_value) * 0.10)
 // <or>
 //     freshnessLifetime = 0
 //
 nsresult
 nsHttpResponseHead::ComputeFreshnessLifetime(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     *result = 0;
 
     // Try HTTP/1.1 style max-age directive...
     if (NS_SUCCEEDED(GetMaxAgeValue_locked(result)))
         return NS_OK;
 
     *result = 0;
 
@@ -758,17 +758,17 @@ nsHttpResponseHead::ComputeFreshnessLife
          "lifetime!\n", this));
 
     return NS_OK;
 }
 
 bool
 nsHttpResponseHead::MustValidate()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     LOG(("nsHttpResponseHead::MustValidate ??\n"));
 
     // Some response codes are cacheable, but the rest are not.  This switch
     // should stay in sync with the list in nsHttpChannel::ProcessResponse
     switch (mStatus) {
         // Success codes
     case 200:
     case 203:
@@ -834,34 +834,34 @@ nsHttpResponseHead::MustValidateIfExpire
     //  a subsequent request without first revalidating it with the origin server.
     //
     return HasHeaderValue(nsHttp::Cache_Control, "must-revalidate");
 }
 
 bool
 nsHttpResponseHead::IsResumable()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     // even though some HTTP/1.0 servers may support byte range requests, we're not
     // going to bother with them, since those servers wouldn't understand If-Range.
     // Also, while in theory it may be possible to resume when the status code
     // is not 200, it is unlikely to be worth the trouble, especially for
     // non-2xx responses.
     return mStatus == 200 &&
            mVersion >= NS_HTTP_VERSION_1_1 &&
            mHeaders.PeekHeader(nsHttp::Content_Length) &&
            (mHeaders.PeekHeader(nsHttp::ETag) ||
             mHeaders.PeekHeader(nsHttp::Last_Modified)) &&
            mHeaders.HasHeaderValue(nsHttp::Accept_Ranges, "bytes");
 }
 
 bool
 nsHttpResponseHead::ExpiresInPast()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return ExpiresInPast_locked();
 }
 
 bool
 nsHttpResponseHead::ExpiresInPast_locked() const
 {
     uint32_t maxAgeVal, expiresVal, dateVal;
 
@@ -875,18 +875,18 @@ nsHttpResponseHead::ExpiresInPast_locked
            expiresVal < dateVal;
 }
 
 nsresult
 nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead *aOther)
 {
     LOG(("nsHttpResponseHead::UpdateHeaders [this=%p]\n", this));
 
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
-    ReentrantMonitorAutoEnter monitorOther(aOther->mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
+    RecursiveMutexAutoLock monitorOther(aOther->mRecursiveMutex);
 
     uint32_t i, count = aOther->mHeaders.Count();
     for (i=0; i<count; ++i) {
         nsHttpAtom header;
         nsAutoCString headerNameOriginal;
         const char *val = aOther->mHeaders.PeekHeaderAt(i, header, headerNameOriginal);
 
         if (!val) {
@@ -930,17 +930,17 @@ nsHttpResponseHead::UpdateHeaders(nsHttp
     return NS_OK;
 }
 
 void
 nsHttpResponseHead::Reset()
 {
     LOG(("nsHttpResponseHead::Reset\n"));
 
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
     mHeaders.Clear();
 
     mVersion = NS_HTTP_VERSION_1_1;
     mStatus = 200;
     mContentLength = -1;
     mCacheControlPrivate = false;
     mCacheControlNoStore = false;
@@ -966,17 +966,17 @@ nsHttpResponseHead::ParseDateHeader(nsHt
 
     *result = PRTimeToSeconds(time);
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::GetAgeValue(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return GetAgeValue_locked(result);
 }
 
 nsresult
 nsHttpResponseHead::GetAgeValue_locked(uint32_t *result) const
 {
     const char *val = mHeaders.PeekHeader(nsHttp::Age);
     if (!val)
@@ -986,17 +986,17 @@ nsHttpResponseHead::GetAgeValue_locked(u
     return NS_OK;
 }
 
 // Return the value of the (HTTP 1.1) max-age directive, which itself is a
 // component of the Cache-Control response header
 nsresult
 nsHttpResponseHead::GetMaxAgeValue(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return GetMaxAgeValue_locked(result);
 }
 
 nsresult
 nsHttpResponseHead::GetMaxAgeValue_locked(uint32_t *result) const
 {
     const char *val = mHeaders.PeekHeader(nsHttp::Cache_Control);
     if (!val)
@@ -1019,24 +1019,24 @@ nsHttpResponseHead::GetMaxAgeValue_locke
         maxAgeValue = 0;
     *result = static_cast<uint32_t>(maxAgeValue);
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::GetDateValue(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return GetDateValue_locked(result);
 }
 
 nsresult
 nsHttpResponseHead::GetExpiresValue(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return GetExpiresValue_locked(result);
 }
 
 nsresult
 nsHttpResponseHead::GetExpiresValue_locked(uint32_t *result) const
 {
     const char *val = mHeaders.PeekHeader(nsHttp::Expires);
     if (!val)
@@ -1056,27 +1056,27 @@ nsHttpResponseHead::GetExpiresValue_lock
     else
         *result = PRTimeToSeconds(time);
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::GetLastModifiedValue(uint32_t *result)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return ParseDateHeader(nsHttp::Last_Modified, result);
 }
 
 bool
 nsHttpResponseHead::operator==(const nsHttpResponseHead& aOther) const
 {
     nsHttpResponseHead &curr = const_cast<nsHttpResponseHead&>(*this);
     nsHttpResponseHead &other = const_cast<nsHttpResponseHead&>(aOther);
-    ReentrantMonitorAutoEnter monitorOther(other.mReentrantMonitor);
-    ReentrantMonitorAutoEnter monitor(curr.mReentrantMonitor);
+    RecursiveMutexAutoLock monitorOther(other.mRecursiveMutex);
+    RecursiveMutexAutoLock monitor(curr.mRecursiveMutex);
 
     return mHeaders == aOther.mHeaders &&
            mVersion == aOther.mVersion &&
            mStatus == aOther.mStatus &&
            mStatusText == aOther.mStatusText &&
            mContentLength == aOther.mContentLength &&
            mContentType == aOther.mContentType &&
            mContentCharset == aOther.mContentCharset &&
@@ -1085,17 +1085,17 @@ nsHttpResponseHead::operator==(const nsH
            mCacheControlNoStore == aOther.mCacheControlNoStore &&
            mCacheControlImmutable == aOther.mCacheControlImmutable &&
            mPragmaNoCache == aOther.mPragmaNoCache;
 }
 
 int64_t
 nsHttpResponseHead::TotalEntitySize()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     const char* contentRange = mHeaders.PeekHeader(nsHttp::Content_Range);
     if (!contentRange)
         return mContentLength;
 
     // Total length is after a slash
     const char* slash = strrchr(contentRange, '/');
     if (!slash)
         return -1; // No idea what the length is
@@ -1213,42 +1213,42 @@ nsHttpResponseHead::ParsePragma(const ch
     if (nsHttp::FindToken(val, "no-cache", HTTP_HEADER_VALUE_SEPS))
         mPragmaNoCache = true;
 }
 
 nsresult
 nsHttpResponseHead::VisitHeaders(nsIHttpHeaderVisitor *visitor,
                                  nsHttpHeaderArray::VisitorFilter filter)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mInVisitHeaders = true;
     nsresult rv = mHeaders.VisitHeaders(visitor, filter);
     mInVisitHeaders = false;
     return rv;
 }
 
 nsresult
 nsHttpResponseHead::GetOriginalHeader(nsHttpAtom aHeader,
                                       nsIHttpHeaderVisitor *aVisitor)
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     mInVisitHeaders = true;
     nsresult rv = mHeaders.GetOriginalHeader(aHeader, aVisitor);
     mInVisitHeaders = false;
     return rv;
 }
 
 bool
 nsHttpResponseHead::HasContentType()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return !mContentType.IsEmpty();
 }
 
 bool
 nsHttpResponseHead::HasContentCharset()
 {
-    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
+    RecursiveMutexAutoLock monitor(mRecursiveMutex);
     return !mContentCharset.IsEmpty();
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/protocol/http/nsHttpResponseHead.h
+++ b/netwerk/protocol/http/nsHttpResponseHead.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsHttpResponseHead_h__
 #define nsHttpResponseHead_h__
 
 #include "nsHttpHeaderArray.h"
 #include "nsHttp.h"
 #include "nsString.h"
-#include "mozilla/ReentrantMonitor.h"
+#include "mozilla/RecursiveMutex.h"
 
 class nsIHttpHeaderVisitor;
 
 // This needs to be forward declared here so we can include only this header
 // without also including PHttpChannelParams.h
 namespace IPC {
     template <typename> struct ParamTraits;
 } // namespace IPC
@@ -32,24 +32,24 @@ public:
     nsHttpResponseHead() : mVersion(NS_HTTP_VERSION_1_1)
                          , mStatus(200)
                          , mContentLength(-1)
                          , mCacheControlPrivate(false)
                          , mCacheControlNoStore(false)
                          , mCacheControlNoCache(false)
                          , mCacheControlImmutable(false)
                          , mPragmaNoCache(false)
-                         , mReentrantMonitor("nsHttpResponseHead.mReentrantMonitor")
+                         , mRecursiveMutex("nsHttpResponseHead.mRecursiveMutex")
                          , mInVisitHeaders(false) {}
 
     nsHttpResponseHead(const nsHttpResponseHead &aOther);
     nsHttpResponseHead &operator=(const nsHttpResponseHead &aOther);
 
-    void Enter() { mReentrantMonitor.Enter(); }
-    void Exit() { mReentrantMonitor.Exit(); }
+    void Enter() { mRecursiveMutex.Lock(); }
+    void Exit() { mRecursiveMutex.Unlock(); }
 
     nsHttpVersion Version();
 // X11's Xlib.h #defines 'Status' to 'int' on some systems!
 #undef Status
     uint16_t Status();
     void StatusText(nsACString &aStatusText);
     int64_t ContentLength();
     void ContentType(nsACString &aContentType);
@@ -180,19 +180,19 @@ private:
     nsCString         mContentType;
     nsCString         mContentCharset;
     bool              mCacheControlPrivate;
     bool              mCacheControlNoStore;
     bool              mCacheControlNoCache;
     bool              mCacheControlImmutable;
     bool              mPragmaNoCache;
 
-    // We are using ReentrantMonitor instead of a Mutex because VisitHeader
+    // We are using RecursiveMutex instead of a Mutex because VisitHeader
     // function calls nsIHttpHeaderVisitor::VisitHeader while under lock.
-    ReentrantMonitor  mReentrantMonitor;
+    RecursiveMutex  mRecursiveMutex;
     // During VisitHeader we sould not allow cal to SetHeader.
     bool              mInVisitHeaders;
 
     friend struct IPC::ParamTraits<nsHttpResponseHead>;
 };
 
 } // namespace net
 } // namespace mozilla