Backed out changeset d34a99623615 (bug 1274509) for bustage on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 24 May 2016 11:22:23 +0200
changeset 337737 7c75ad684ce25c3e1d3629a18201e29c9a79b6bf
parent 337736 5b9cf20ae1bc67f2515a9fcded190e2324444246
child 337738 8a2859f10ae0ace5f6a726e78f2fa4686b5db75d
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1274509
milestone49.0a1
backs outd34a9962361534223971dee4fbbff85de9b12c06
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
Backed out changeset d34a99623615 (bug 1274509) for bustage on a CLOSED TREE
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/nsHttpRequestHead.cpp
netwerk/protocol/http/nsHttpRequestHead.h
netwerk/protocol/http/nsIHttpChannel.idl
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1238,20 +1238,17 @@ HttpBaseChannel::GetReferrerPolicy(uint3
 NS_IMETHODIMP
 HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
                                        uint32_t referrerPolicy)
 {
   ENSURE_CALLED_BEFORE_CONNECT();
 
   // clear existing referrer, if any
   mReferrer = nullptr;
-  nsresult rv = mRequestHead.ClearHeader(nsHttp::Referer);
-  if(NS_FAILED(rv)) {
-    return rv;
-  }
+  mRequestHead.ClearHeader(nsHttp::Referer);
   mReferrerPolicy = REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE;
 
   if (!referrer) {
     return NS_OK;
   }
 
   // Don't send referrer at all when the meta referrer setting is "no-referrer"
   if (referrerPolicy == REFERRER_POLICY_NO_REFERRER) {
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -1052,33 +1052,33 @@ HttpChannelParent::OnStartRequest(nsIReq
 
     nsresult rv = container->GetData(&cacheKeyValue);
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   // !!! We need to lock headers and please don't forget to unlock them !!!
-  requestHead->Enter();
+  requestHead->Lock();
   nsresult rv = NS_OK;
   if (mIPCClosed ||
       !SendOnStartRequest(channelStatus,
                           responseHead ? *responseHead : nsHttpResponseHead(),
                           !!responseHead,
                           requestHead->Headers(),
                           isFromCache,
                           mCacheEntry ? true : false,
                           expirationTime, cachedCharset, secInfoSerialization,
                           mChannel->GetSelfAddr(), mChannel->GetPeerAddr(),
                           redirectCount,
                           cacheKeyValue))
   {
     rv = NS_ERROR_UNEXPECTED;
   }
-  requestHead->Exit();
+  requestHead->Unlock();
   return rv;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
                                  nsISupports *aContext,
                                  nsresult aStatusCode)
 {
--- a/netwerk/protocol/http/nsHttpRequestHead.cpp
+++ b/netwerk/protocol/http/nsHttpRequestHead.cpp
@@ -16,246 +16,211 @@
 namespace mozilla {
 namespace net {
 
 nsHttpRequestHead::nsHttpRequestHead()
     : mMethod(NS_LITERAL_CSTRING("GET"))
     , mVersion(NS_HTTP_VERSION_1_1)
     , mParsedMethod(kMethod_Get)
     , mHTTPS(false)
-    , mReentrantMonitor("nsHttpRequestHead.mReentrantMonitor")
-    , mInVisitHeaders(false)
+    , mLock("nsHttpRequestHead.mLock")
 {
     MOZ_COUNT_CTOR(nsHttpRequestHead);
 }
 
 nsHttpRequestHead::~nsHttpRequestHead()
 {
     MOZ_COUNT_DTOR(nsHttpRequestHead);
 }
 
 // Don't use this function. It is only used by HttpChannelParent to avoid
 // copying of request headers!!!
 const nsHttpHeaderArray &
 nsHttpRequestHead::Headers() const
 {
-    nsHttpRequestHead &curr = const_cast<nsHttpRequestHead&>(*this);
-    curr.mReentrantMonitor.AssertCurrentThreadIn();
+    mLock.AssertCurrentThreadOwns();
     return mHeaders;
 }
 
 void
 nsHttpRequestHead::SetHeaders(const nsHttpHeaderArray& aHeaders)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mHeaders = aHeaders;
 }
 
 void
 nsHttpRequestHead::SetVersion(nsHttpVersion version)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mVersion = version;
 }
 
 void
 nsHttpRequestHead::SetRequestURI(const nsCSubstring &s)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mRequestURI = s;
 }
 
 void
 nsHttpRequestHead::SetPath(const nsCSubstring &s)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mPath = s;
 }
 
 uint32_t
 nsHttpRequestHead::HeaderCount()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mHeaders.Count();
 }
 
 nsresult
 nsHttpRequestHead::VisitHeaders(nsIHttpHeaderVisitor *visitor,
                                 nsHttpHeaderArray::VisitorFilter filter /* = nsHttpHeaderArray::eFilterAll*/)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-    mInVisitHeaders = true;
-    nsresult rv = mHeaders.VisitHeaders(visitor, filter);
-    mInVisitHeaders = false;
-    return rv;
+    MutexAutoLock lock(mLock);
+    return mHeaders.VisitHeaders(visitor, filter);
 }
 
 void
 nsHttpRequestHead::Method(nsACString &aMethod)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     aMethod = mMethod;
 }
 
 nsHttpVersion
 nsHttpRequestHead::Version()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mVersion;
 }
 
 void
 nsHttpRequestHead::RequestURI(nsACString &aRequestURI)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     aRequestURI = mRequestURI;
 }
 
 void
 nsHttpRequestHead::Path(nsACString &aPath)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     aPath = mPath.IsEmpty() ? mRequestURI : mPath;
 }
 
 void
 nsHttpRequestHead::SetHTTPS(bool val)
 {
-    ReentrantMonitorAutoEnter monk(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mHTTPS = val;
 }
 
 void
 nsHttpRequestHead::Origin(nsACString &aOrigin)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     aOrigin = mOrigin;
 }
 
 nsresult
 nsHttpRequestHead::SetHeader(nsHttpAtom h, const nsACString &v,
                              bool m /*= false*/)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return NS_ERROR_FAILURE;
-    }
-
+    MutexAutoLock lock(mLock);
     return mHeaders.SetHeader(h, v, m,
                               nsHttpHeaderArray::eVarietyRequestOverride);
 }
 
 nsresult
 nsHttpRequestHead::SetHeader(nsHttpAtom h, const nsACString &v, bool m,
                              nsHttpHeaderArray::HeaderVariety variety)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return NS_ERROR_FAILURE;
-    }
-
+    MutexAutoLock lock(mLock);
     return mHeaders.SetHeader(h, v, m, variety);
 }
 
 nsresult
 nsHttpRequestHead::SetEmptyHeader(nsHttpAtom h)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return NS_ERROR_FAILURE;
-    }
-
+    MutexAutoLock lock(mLock);
     return mHeaders.SetEmptyHeader(h,
                                    nsHttpHeaderArray::eVarietyRequestOverride);
 }
 
 nsresult
 nsHttpRequestHead::GetHeader(nsHttpAtom h, nsACString &v)
 {
     v.Truncate();
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mHeaders.GetHeader(h, v);
 }
 
 void
 nsHttpRequestHead::ClearHeader(nsHttpAtom h)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return;
-    }
-
+    MutexAutoLock lock(mLock);
     mHeaders.ClearHeader(h);
 }
 
 void
 nsHttpRequestHead::ClearHeaders()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return;
-    }
-
+    MutexAutoLock lock(mLock);
     mHeaders.Clear();
 }
 
 bool
 nsHttpRequestHead::HasHeader(nsHttpAtom h)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-    return mHeaders.HasHeader(h);
+  MutexAutoLock lock(mLock);
+  return mHeaders.HasHeader(h);
 }
 
 bool
 nsHttpRequestHead::HasHeaderValue(nsHttpAtom h, const char *v)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mHeaders.HasHeaderValue(h, v);
 }
 
 nsresult
 nsHttpRequestHead::SetHeaderOnce(nsHttpAtom h, const char *v,
                                  bool merge /*= false */)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
-
-    if (mInVisitHeaders) {
-        return NS_ERROR_FAILURE;
-    }
-
+    MutexAutoLock lock(mLock);
     if (!merge || !mHeaders.HasHeaderValue(h, v)) {
         return mHeaders.SetHeader(h, nsDependentCString(v), merge,
                                   nsHttpHeaderArray::eVarietyRequestOverride);
     }
     return NS_OK;
 }
 
 nsHttpRequestHead::ParsedMethodType
 nsHttpRequestHead::ParsedMethod()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mParsedMethod;
 }
 
 bool
 nsHttpRequestHead::EqualsMethod(ParsedMethodType aType)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mParsedMethod == aType;
 }
 
 void
 nsHttpRequestHead::ParseHeaderSet(char *buffer)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     nsHttpAtom hdr;
     char *val;
     while (buffer) {
         char *eof = strchr(buffer, '\r');
         if (!eof) {
             break;
         }
         *eof = '\0';
@@ -269,24 +234,24 @@ nsHttpRequestHead::ParseHeaderSet(char *
             buffer++;
         }
     }
 }
 
 bool
 nsHttpRequestHead::IsHTTPS()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     return mHTTPS;
 }
 
 void
 nsHttpRequestHead::SetMethod(const nsACString &method)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mParsedMethod = kMethod_Custom;
     mMethod = method;
     if (!strcmp(mMethod.get(), "GET")) {
         mParsedMethod = kMethod_Get;
     } else if (!strcmp(mMethod.get(), "POST")) {
         mParsedMethod = kMethod_Post;
     } else if (!strcmp(mMethod.get(), "OPTIONS")) {
         mParsedMethod = kMethod_Options;
@@ -300,30 +265,30 @@ nsHttpRequestHead::SetMethod(const nsACS
         mParsedMethod = kMethod_Trace;
     }
 }
 
 void
 nsHttpRequestHead::SetOrigin(const nsACString &scheme, const nsACString &host,
                              int32_t port)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     mOrigin.Assign(scheme);
     mOrigin.Append(NS_LITERAL_CSTRING("://"));
     mOrigin.Append(host);
     if (port >= 0) {
         mOrigin.Append(NS_LITERAL_CSTRING(":"));
         mOrigin.AppendInt(port);
     }
 }
 
 bool
 nsHttpRequestHead::IsSafeMethod()
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     // This code will need to be extended for new safe methods, otherwise
     // they'll default to "not safe".
     if ((mParsedMethod == kMethod_Get) || (mParsedMethod == kMethod_Head) ||
         (mParsedMethod == kMethod_Options) || (mParsedMethod == kMethod_Trace)
        ) {
         return true;
     }
 
@@ -334,17 +299,17 @@ nsHttpRequestHead::IsSafeMethod()
     return (!strcmp(mMethod.get(), "PROPFIND") ||
             !strcmp(mMethod.get(), "REPORT") ||
             !strcmp(mMethod.get(), "SEARCH"));
 }
 
 void
 nsHttpRequestHead::Flatten(nsACString &buf, bool pruneProxyHeaders)
 {
-    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+    MutexAutoLock lock(mLock);
     // note: the first append is intentional.
 
     buf.Append(mMethod);
     buf.Append(' ');
     buf.Append(mRequestURI);
     buf.AppendLiteral(" HTTP/");
 
     switch (mVersion) {
--- a/netwerk/protocol/http/nsHttpRequestHead.h
+++ b/netwerk/protocol/http/nsHttpRequestHead.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsHttpRequestHead_h__
 #define nsHttpRequestHead_h__
 
 #include "nsHttp.h"
 #include "nsHttpHeaderArray.h"
 #include "nsString.h"
-#include "mozilla/ReentrantMonitor.h"
+#include "mozilla/Mutex.h"
 
 class nsIHttpHeaderVisitor;
 
 namespace mozilla { namespace net {
 
 //-----------------------------------------------------------------------------
 // nsHttpRequestHead represents the request line and headers from an HTTP
 // request.
@@ -25,18 +25,18 @@ class nsHttpRequestHead
 public:
     nsHttpRequestHead();
     ~nsHttpRequestHead();
 
     // The following function is only used in HttpChannelParent to avoid
     // copying headers. If you use it be careful to do it only under
     // nsHttpRequestHead lock!!!
     const nsHttpHeaderArray &Headers() const;
-    void Enter() { mReentrantMonitor.Enter(); }
-    void Exit() { mReentrantMonitor.Exit(); }
+    void Lock() { mLock.Lock(); }
+    void Unlock() { mLock.Unlock(); }
 
     void SetHeaders(const nsHttpHeaderArray& aHeaders);
 
     void SetMethod(const nsACString &method);
     void SetVersion(nsHttpVersion version);
     void SetRequestURI(const nsCSubstring &s);
     void SetPath(const nsCSubstring &s);
     uint32_t HeaderCount();
@@ -109,20 +109,15 @@ private:
     // because this is used off the main thread
     nsCString         mRequestURI;
     nsCString         mPath;
 
     nsCString         mOrigin;
     ParsedMethodType  mParsedMethod;
     bool              mHTTPS;
 
-    // We are using ReentrantMonitor instead of a Mutex because VisitHeader
-    // function calls nsIHttpHeaderVisitor::VisitHeader while under lock. 
-    ReentrantMonitor  mReentrantMonitor;
-
-    // During VisitHeader we sould not allow cal to SetHeader.
-    bool mInVisitHeaders;
+    Mutex             mLock;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // nsHttpRequestHead_h__
--- a/netwerk/protocol/http/nsIHttpChannel.idl
+++ b/netwerk/protocol/http/nsIHttpChannel.idl
@@ -47,18 +47,16 @@ interface nsIHttpChannel : nsIChannel
      *
      * NOTE: The channel may silently refuse to set the Referer header if the
      * URI does not pass certain security checks (e.g., a "https://" URL will
      * never be sent as the referrer for a plaintext HTTP request).  The
      * implementation is not required to throw an exception when the referrer
      * URI is rejected.
      *
      * @throws NS_ERROR_IN_PROGRESS if set after the channel has been opened.
-     * @throws NS_ERROR_FAILURE if used for setting referrer during
-     *         visitRequestHeaders. Getting the value will not throw.
      */
     attribute nsIURI referrer;
 
     /**
      * Referrer policies. See ReferrerPolicy.h for more details.
      */
 
 
@@ -83,17 +81,16 @@ interface nsIHttpChannel : nsIChannel
      * Get the HTTP referrer policy.  The policy is retrieved from the meta
      * referrer tag, which can be one of many values (see ReferrerPolicy.h for
      * more details).
      */
     readonly attribute unsigned long referrerPolicy;
 
     /**
      * Set the HTTP referrer URI with a referrer policy.
-     * @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
      */
     void setReferrerWithPolicy(in nsIURI referrer, in unsigned long referrerPolicy);
 
     /**
      * Returns the network protocol used to fetch the resource as identified
      * by the ALPN Protocol ID.
      *
      * @throws NS_ERROR_NOT_AVAILABLE if called before the response
@@ -150,17 +147,16 @@ interface nsIHttpChannel : nsIChannel
      *        which this flag is ignored is an implementation detail.  If this
      *        flag is false, then the header value will be replaced with the
      *        contents of |aValue|.
      *
      * If aValue is empty and aMerge is false, the header will be cleared.
      *
      * @throws NS_ERROR_IN_PROGRESS if called after the channel has been
      *         opened.
-     * @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
      */
     void setRequestHeader(in ACString aHeader,
                           in ACString aValue,
                           in boolean aMerge);
 
     /**
      * Set a request header with empty value.
      *
@@ -170,17 +166,16 @@ interface nsIHttpChannel : nsIChannel
      * This method may only be called before the channel is opened.
      *
      * @param aHeader
      *        The case-insensitive name of the request header to set (e.g.,
      *        "Cookie").
      *
      * @throws NS_ERROR_IN_PROGRESS if called after the channel has been
      *         opened.
-     * @throws NS_ERROR_FAILURE if called during visitRequestHeaders.
      */
     void setEmptyRequestHeader(in ACString aHeader);
 
     /**
      * Call this method to visit all request headers.  Calling setRequestHeader
      * while visiting request headers has undefined behavior.  Don't do it!
      *
      * @param aVisitor