Backed out 2 changesets (bug 1448034) for GTest failures
authorCoroiu Cristina <ccoroiu@mozilla.com>
Tue, 17 Jul 2018 08:51:20 +0300
changeset 484663 3e7a177e2e84deab47b84bc56a197ce7d39d3c13
parent 484662 9175b19b1b4933aeb879323f059f4be1efadba28
child 484664 0486cd62a807989f85459e360f015bdb1b7a0cf1
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1448034
milestone63.0a1
backs out068bb4e7b8494d8ae82dfd1b1f22680234bf038c
eb542860b989d4f6ea1ffcb29ff843b857d78482
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 2 changesets (bug 1448034) for GTest failures Backed out changeset 068bb4e7b849 (bug 1448034) Backed out changeset eb542860b989 (bug 1448034)
netwerk/base/ProxyAutoConfig.cpp
netwerk/base/nsPACMan.cpp
netwerk/base/nsPACMan.h
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsProtocolProxyService.h
--- a/netwerk/base/ProxyAutoConfig.cpp
+++ b/netwerk/base/ProxyAutoConfig.cpp
@@ -407,17 +407,17 @@ bool PACResolve(const nsCString &aHostNa
   }
 
   return GetRunning()->ResolveAddress(aHostName, aNetAddr, aTimeout);
 }
 
 ProxyAutoConfig::ProxyAutoConfig()
   : mJSContext(nullptr)
   , mJSNeedsSetup(false)
-  , mShutdown(true)
+  , mShutdown(false)
   , mIncludePath(false)
   , mExtraHeapSize(0)
 {
   MOZ_COUNT_CTOR(ProxyAutoConfig);
 }
 
 bool
 ProxyAutoConfig::ResolveAddress(const nsCString &aHostName,
@@ -699,18 +699,16 @@ ProxyAutoConfig::SetThreadLocalIndex(uin
 
 nsresult
 ProxyAutoConfig::Init(const nsCString &aPACURI,
                       const nsCString &aPACScript,
                       bool aIncludePath,
                       uint32_t aExtraHeapSize,
                       nsIEventTarget *aEventTarget)
 {
-  mShutdown = false; // Shutdown needs to be called prior to destruction
-
   mPACURI = aPACURI;
   mPACScript = sPacUtils;
   mPACScript.Append(aPACScript);
   mIncludePath = aIncludePath;
   mExtraHeapSize = aExtraHeapSize;
   mMainThreadEventTarget = aEventTarget;
 
   if (!GetRunning())
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -14,18 +14,16 @@
 #include "nsIHttpChannel.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIPromptFactory.h"
 #include "nsIProtocolProxyService.h"
 #include "nsISystemProxySettings.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
-#include "mozilla/Result.h"
-#include "mozilla/ResultExtensions.h"
 
 //-----------------------------------------------------------------------------
 
 namespace mozilla {
 namespace net {
 
 LazyLogModule gProxyLog("proxy");
 
@@ -263,24 +261,22 @@ public:
   explicit ExecutePACThreadAction(nsPACMan* aPACMan)
     : Runnable("net::ExecutePACThreadAction")
     , mPACMan(aPACMan)
     , mCancel(false)
     , mCancelStatus(NS_OK)
     , mSetupPAC(false)
     , mExtraHeapSize(0)
     , mConfigureWPAD(false)
-    , mShutdown(false)
   { }
 
-  void CancelQueue (nsresult status, bool aShutdown)
+  void CancelQueue (nsresult status)
   {
     mCancel = true;
     mCancelStatus = status;
-    mShutdown = aShutdown;
   }
 
   void SetupPAC (const char *text,
                  uint32_t datalen,
                  const nsACString &pacURI,
                  uint32_t extraHeapSize)
   {
     mSetupPAC = true;
@@ -293,17 +289,17 @@ public:
   {
     mConfigureWPAD = true;
   }
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
     if (mCancel) {
-      mPACMan->CancelPendingQ(mCancelStatus, mShutdown);
+      mPACMan->CancelPendingQ(mCancelStatus);
       mCancel = false;
       return NS_OK;
     }
 
     if (mSetupPAC) {
       mSetupPAC = false;
 
       nsCOMPtr<nsIEventTarget> target = mPACMan->GetNeckoTarget();
@@ -337,17 +333,16 @@ private:
   bool      mCancel;
   nsresult  mCancelStatus;
 
   bool                 mSetupPAC;
   uint32_t             mExtraHeapSize;
   nsCString            mSetupPACData;
   nsCString            mSetupPACURI;
   bool                 mConfigureWPAD;
-  bool                 mShutdown;
 };
 
 //-----------------------------------------------------------------------------
 
 PendingPACQuery::PendingPACQuery(nsPACMan* pacMan,
                                  nsIURI* uri,
                                  nsPACManCallback* callback,
                                  bool mainThreadResponse)
@@ -446,50 +441,24 @@ nsPACMan::~nsPACMan()
 
 void
 nsPACMan::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread(), "pacman must be shutdown on main thread");
   if (mShutdown) {
     return;
   }
-
+  mShutdown = true;
   CancelExistingLoad();
 
-  if (mPACThread) {
-    PostCancelPendingQ(NS_ERROR_ABORT, /*aShutdown =*/ true);
-
-    // Shutdown is initiated from an observer. We don't want to block the
-    // observer service on thread shutdown so we post a shutdown runnable that
-    // will run after we return instead.
-    RefPtr<WaitForThreadShutdown> runnable = new WaitForThreadShutdown(this);
-    Dispatch(runnable.forget());
-  }
-
-  mShutdown = true;
-}
+  MOZ_ASSERT(mPACThread, "mPAC requires mPACThread to shutdown");
+  PostCancelPendingQ(NS_ERROR_ABORT);
 
-nsresult
-nsPACMan::DispatchToPAC(already_AddRefed<nsIRunnable> aEvent)
-{
-  MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
-
-  nsCOMPtr<nsIRunnable> e(aEvent);
-
-  if (mShutdown) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  // Lazily create the PAC thread. This method is main-thread only so we don't
-  // have to worry about threading issues here.
-  if (!mPACThread) {
-    MOZ_TRY(NS_NewNamedThread("ProxyResolution", getter_AddRefs(mPACThread)));
-  }
-
-  return mPACThread->Dispatch(e.forget(), nsIEventTarget::DISPATCH_NORMAL);
+  RefPtr<WaitForThreadShutdown> runnable = new WaitForThreadShutdown(this);
+  Dispatch(runnable.forget());
 }
 
 nsresult
 nsPACMan::AsyncGetProxyForURI(nsIURI *uri,
                               nsPACManCallback *callback,
                               bool mainThreadResponse)
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
@@ -508,17 +477,17 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *ur
     new PendingPACQuery(this, uri, callback, mainThreadResponse);
 
   if (IsPACURI(uri)) {
     // deal with this directly instead of queueing it
     query->Complete(NS_OK, EmptyCString());
     return NS_OK;
   }
 
-  return DispatchToPAC(query.forget());
+  return mPACThread->Dispatch(query, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 nsresult
 nsPACMan::PostQuery(PendingPACQuery *query)
 {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
 
   if (mShutdown) {
@@ -636,17 +605,19 @@ nsPACMan::StartLoading()
     return;
   }
 
   if (mAutoDetect) {
     GetNetworkProxyTypeFromPref(&mProxyConfigType);
     RefPtr<ExecutePACThreadAction> wpadConfigurer =
       new ExecutePACThreadAction(this);
     wpadConfigurer->ConfigureWPAD();
-    DispatchToPAC(wpadConfigurer.forget());
+    if (mPACThread) {
+      mPACThread->Dispatch(wpadConfigurer, nsIEventTarget::DISPATCH_NORMAL);
+    }
   } else {
     ContinueLoadingAfterPACUriKnown();
   }
 }
 
 void
 nsPACMan::ContinueLoadingAfterPACUriKnown()
 {
@@ -740,41 +711,43 @@ nsPACMan::CancelExistingLoad()
 }
 
 void
 nsPACMan::PostProcessPendingQ()
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   RefPtr<ExecutePACThreadAction> pending =
     new ExecutePACThreadAction(this);
-  DispatchToPAC(pending.forget());
+  if (mPACThread)
+    mPACThread->Dispatch(pending, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 void
-nsPACMan::PostCancelPendingQ(nsresult status, bool aShutdown)
+nsPACMan::PostCancelPendingQ(nsresult status)
 {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   RefPtr<ExecutePACThreadAction> pending =
     new ExecutePACThreadAction(this);
-  pending->CancelQueue(status, aShutdown);
-  DispatchToPAC(pending.forget());
+  pending->CancelQueue(status);
+  if (mPACThread)
+    mPACThread->Dispatch(pending, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 void
-nsPACMan::CancelPendingQ(nsresult status, bool aShutdown)
+nsPACMan::CancelPendingQ(nsresult status)
 {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
   RefPtr<PendingPACQuery> query;
 
   while (!mPendingQ.isEmpty()) {
     query = dont_AddRef(mPendingQ.popLast());
     query->Complete(status, EmptyCString());
   }
 
-  if (aShutdown)
+  if (mShutdown)
     mPAC.Shutdown();
 }
 
 void
 nsPACMan::ProcessPendingQ()
 {
   MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
   while (ProcessPending());
@@ -891,17 +864,18 @@ nsPACMan::OnStreamComplete(nsIStreamLoad
     // we have succeeded in loading the pac file using a bunch of interfaces that
     // are main thread only, unfortunately we have to initialize the instance of
     // the PAC evaluator (NS_PROXYAUTOCONFIG_CONTRACTID) on the pac thread, because
     // that is where it will be used.
 
     RefPtr<ExecutePACThreadAction> pending =
       new ExecutePACThreadAction(this);
     pending->SetupPAC(text, dataLen, pacURI, GetExtraJSContextHeapSize());
-    DispatchToPAC(pending.forget());
+    if (mPACThread)
+      mPACThread->Dispatch(pending, nsIEventTarget::DISPATCH_NORMAL);
 
     LOG(("OnStreamComplete: process the PAC contents\n"));
 
     // Even if the PAC file could not be parsed, we did succeed in loading the
     // data for it.
     mLoadFailureCount = 0;
   } else {
     // We were unable to load the PAC file (presumably because of a network
@@ -967,13 +941,17 @@ nsPACMan::AsyncOnChannelRedirect(nsIChan
   return NS_OK;
 }
 
 nsresult
 nsPACMan::Init(nsISystemProxySettings *systemProxySettings)
 {
   mSystemProxySettings = systemProxySettings;
   mDHCPClient = do_GetService(NS_DHCPCLIENT_CONTRACTID);
-  return NS_OK;
+
+  nsresult rv =
+    NS_NewNamedThread("ProxyResolution", getter_AddRefs(mPACThread));
+
+  return rv;
 }
 
 } // namespace net
-} // namespace mozilla
+} // namespace mozilla
\ No newline at end of file
--- a/netwerk/base/nsPACMan.h
+++ b/netwerk/base/nsPACMan.h
@@ -171,17 +171,17 @@ public:
     return mAutoDetect;
   }
 
   nsresult Init(nsISystemProxySettings *);
   static nsPACMan *sInstance;
 
   // PAC thread operations only
   void ProcessPendingQ();
-  void CancelPendingQ(nsresult, bool aShutdown);
+  void CancelPendingQ(nsresult);
 
   void SetWPADOverDHCPEnabled(bool aValue) { mWPADOverDHCPEnabled = aValue; }
 
 private:
   NS_DECL_NSISTREAMLOADEROBSERVER
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSICHANNELEVENTSINK
 
@@ -227,28 +227,22 @@ private:
   nsresult PostQuery(PendingPACQuery *query);
 
   // Having found the PAC URI on the PAC thread, copy it to a string which
   // can be altered on the main thread.
   void AssignPACURISpec(const nsACString &aSpec);
 
   // PAC thread operations only
   void PostProcessPendingQ();
-  void PostCancelPendingQ(nsresult, bool aShutdown = false);
+  void PostCancelPendingQ(nsresult);
   bool ProcessPending();
   nsresult GetPACFromDHCP(nsACString &aSpec);
   nsresult ConfigureWPAD(nsACString &aSpec);
 
 private:
-  /**
-   * Dispatches a runnable to the PAC processing thread. Handles lazy
-   * instantiation of the thread.
-   */
-  nsresult DispatchToPAC(already_AddRefed<nsIRunnable> aEvent);
-
   ProxyAutoConfig mPAC;
   nsCOMPtr<nsIThread>           mPACThread;
   nsCOMPtr<nsISystemProxySettings> mSystemProxySettings;
   nsCOMPtr<nsIDHCPClient> mDHCPClient;
 
   LinkedList<PendingPACQuery> mPendingQ; /* pac thread only */
 
   // These specs are not nsIURI so that they can be used off the main thread.
@@ -271,9 +265,9 @@ private:
   int32_t                      mProxyConfigType;
 };
 
 extern LazyLogModule gProxyLog;
 
 } // namespace net
 } // namespace mozilla
 
-#endif  // nsPACMan_h__
+#endif  // nsPACMan_h__
\ No newline at end of file
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -834,17 +834,17 @@ nsProtocolProxyService::~nsProtocolProxy
     NS_ASSERTION(mHostFiltersArray.Length() == 0 && mFilters.Length() == 0 &&
                  mPACMan == nullptr, "what happened to xpcom-shutdown?");
 }
 
 // nsProtocolProxyService methods
 nsresult
 nsProtocolProxyService::Init()
 {
-    mProxySettingTarget = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
+    NS_NewNamedThread("SysProxySetting", getter_AddRefs(mProxySettingThread));
 
     // failure to access prefs is non-fatal
     nsCOMPtr<nsIPrefBranch> prefBranch =
             do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefBranch) {
         // monitor proxy prefs
         prefBranch->AddObserver(PROXY_PREF_BRANCH, this, false);
 
@@ -928,20 +928,20 @@ nsProtocolProxyService::AsyncConfigureFr
                                   mainThreadOnly,
                                   aForceReload,
                                   aResetPACThread);
 
     if (mainThreadOnly) {
         return req->Run();
     }
 
-    if (NS_WARN_IF(!mProxySettingTarget)) {
+    if (NS_WARN_IF(!mProxySettingThread)) {
         return NS_ERROR_NOT_INITIALIZED;
     }
-    return mProxySettingTarget->Dispatch(req, nsIEventTarget::DISPATCH_NORMAL);
+    return mProxySettingThread->Dispatch(req, nsIEventTarget::DISPATCH_NORMAL);
 }
 
 nsresult
 nsProtocolProxyService::OnAsyncGetPACURI(bool aForceReload,
                                          bool aResetPACThread,
                                          nsresult aResult,
                                          const nsACString& aUri)
 {
@@ -969,18 +969,19 @@ nsProtocolProxyService::Observe(nsISuppo
         mHostFiltersArray.Clear();
         mFilters.Clear();
 
         if (mPACMan) {
             mPACMan->Shutdown();
             mPACMan = nullptr;
         }
 
-        if (mProxySettingTarget) {
-            mProxySettingTarget = nullptr;
+        if (mProxySettingThread) {
+            mProxySettingThread->Shutdown();
+            mProxySettingThread = nullptr;
         }
 
         nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
         if (obs) {
             obs->RemoveObserver(this, NS_NETWORK_LINK_TOPIC);
             obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
         }
 
--- a/netwerk/base/nsProtocolProxyService.h
+++ b/netwerk/base/nsProtocolProxyService.h
@@ -411,17 +411,17 @@ protected:
 
 private:
     nsresult AsyncResolveInternal(nsIChannel *channel, uint32_t flags,
                                   nsIProtocolProxyCallback *callback,
                                   nsICancelable **result,
                                   bool isSyncOK,
                                   nsIEventTarget *mainThreadEventTarget);
     bool                          mIsShutdown;
-    nsCOMPtr<nsIEventTarget> mProxySettingTarget;
+    nsCOMPtr<nsIThread>           mProxySettingThread;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsProtocolProxyService, NS_PROTOCOL_PROXY_SERVICE_IMPL_CID)
 
 } // namespace net
 } // namespace mozilla
 
 #endif // !nsProtocolProxyService_h__
\ No newline at end of file