Port bug 1620594 part 1: Change NS_ReleaseOnMainThreadSystemGroup to NS_ReleaseOnMainThread. rs=bustage-fix
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 08 Apr 2020 10:46:32 +1200
changeset 38742 25b29578a1467e2ad16bc9348ef9709210c0294e
parent 38741 7e335f6ec5031c49f4b455929196f1984d59f79e
child 38743 3f497398788daab69b15f64d49ea1d18cdafbccc
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersbustage-fix
bugs1620594
Port bug 1620594 part 1: Change NS_ReleaseOnMainThreadSystemGroup to NS_ReleaseOnMainThread. rs=bustage-fix
ldap/xpcom/src/nsLDAPConnection.cpp
mailnews/base/util/nsMsgMailNewsUrl.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsSyncRunnableHelpers.cpp
mailnews/imap/src/nsSyncRunnableHelpers.h
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -598,18 +598,18 @@ nsLDAPConnection::OnLookupByTypeComplete
 
 nsLDAPConnectionRunnable::nsLDAPConnectionRunnable(
     int32_t aOperationID, nsILDAPOperation *aOperation,
     nsLDAPConnection *aConnection)
     : mOperationID(aOperationID), mConnection(aConnection) {}
 
 nsLDAPConnectionRunnable::~nsLDAPConnectionRunnable() {
   if (mConnection) {
-    NS_ReleaseOnMainThreadSystemGroup("nsLDAPConnectionRunnable::mConnection",
-                                      mConnection.forget());
+    NS_ReleaseOnMainThread("nsLDAPConnectionRunnable::mConnection",
+                           mConnection.forget());
   }
 }
 
 NS_IMPL_ISUPPORTS(nsLDAPConnectionRunnable, nsIRunnable)
 
 NS_IMETHODIMP nsLDAPConnectionRunnable::Run() {
   if (!mOperationID) {
     NS_ERROR("mOperationID is null");
--- a/mailnews/base/util/nsMsgMailNewsUrl.cpp
+++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp
@@ -53,32 +53,31 @@ nsMsgMailNewsUrl::nsMsgMailNewsUrl() {
   }                                                                 \
   PR_END_MACRO
 
 nsMsgMailNewsUrl::~nsMsgMailNewsUrl() {
   // In IMAP this URL is created and destroyed on the imap thread,
   // so we must ensure that releases of XPCOM objects (which might be
   // implemented by non-threadsafe JS components) are released on the
   // main thread.
-  NS_ReleaseOnMainThreadSystemGroup("nsMsgMailNewsUrl::m_baseURL",
-                                    m_baseURL.forget());
-  NS_ReleaseOnMainThreadSystemGroup("nsMsgMailNewsUrl::mMimeHeaders",
-                                    mMimeHeaders.forget());
-  NS_ReleaseOnMainThreadSystemGroup("nsMsgMailNewsUrl::m_searchSession",
-                                    m_searchSession.forget());
-  NS_ReleaseOnMainThreadSystemGroup("nsMsgMailNewsUrl::mMsgHeaderSink",
-                                    mMsgHeaderSink.forget());
+  NS_ReleaseOnMainThread("nsMsgMailNewsUrl::m_baseURL", m_baseURL.forget());
+  NS_ReleaseOnMainThread("nsMsgMailNewsUrl::mMimeHeaders",
+                         mMimeHeaders.forget());
+  NS_ReleaseOnMainThread("nsMsgMailNewsUrl::m_searchSession",
+                         m_searchSession.forget());
+  NS_ReleaseOnMainThread("nsMsgMailNewsUrl::mMsgHeaderSink",
+                         mMsgHeaderSink.forget());
 
   nsTObserverArray<nsCOMPtr<nsIUrlListener>>::ForwardIterator iter(
       mUrlListeners);
   while (iter.HasMore()) {
     nsCOMPtr<nsIUrlListener> listener = iter.GetNext();
     if (listener)
-      NS_ReleaseOnMainThreadSystemGroup("nsMsgMailNewsUrl::mUrlListeners",
-                                        listener.forget());
+      NS_ReleaseOnMainThread("nsMsgMailNewsUrl::mUrlListeners",
+                             listener.forget());
   }
 }
 
 NS_IMPL_ADDREF(nsMsgMailNewsUrl)
 NS_IMPL_RELEASE(nsMsgMailNewsUrl)
 
 // We want part URLs to QI to nsIURIWithSpecialOrigin so we can give
 // them a "normalized" origin. URLs that already have a "normalized"
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -101,18 +101,18 @@ static const PRIntervalTime kImapSleepTi
 static int32_t gPromoteNoopToCheckCount = 0;
 static const uint32_t kFlagChangesBeforeCheck = 10;
 static const int32_t kMaxSecondsBeforeCheck = 600;
 
 class AutoProxyReleaseMsgWindow {
  public:
   AutoProxyReleaseMsgWindow() : mMsgWindow() {}
   ~AutoProxyReleaseMsgWindow() {
-    NS_ReleaseOnMainThreadSystemGroup("AutoProxyReleaseMsgWindow::mMsgWindow",
-                                      dont_AddRef(mMsgWindow));
+    NS_ReleaseOnMainThread("AutoProxyReleaseMsgWindow::mMsgWindow",
+                           dont_AddRef(mMsgWindow));
   }
   nsIMsgWindow **StartAssignment() {
     MOZ_ASSERT(!mMsgWindow);
     return &mMsgWindow;
   }
   operator nsIMsgWindow *() { return mMsgWindow; }
 
  private:
@@ -1014,32 +1014,32 @@ void nsImapProtocol::ReleaseUrlState(boo
 
     {
       // grab a lock so m_mockChannel doesn't get cleared out
       // from under us.
       MutexAutoLock mon(mLock);
       if (m_mockChannel) {
         // Proxy the release of the channel to the main thread.  This is
         // something that the xpcom proxy system should do for us!
-        NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::m_mockChannel",
-                                          m_mockChannel.forget());
+        NS_ReleaseOnMainThread("nsImapProtocol::m_mockChannel",
+                               m_mockChannel.forget());
       }
     }
   }
 
   m_imapMessageSink = nullptr;
 
   // Proxy the release of the listener to the main thread.  This is something
   // that the xpcom proxy system should do for us!
   {
     // grab a lock so the m_channelListener doesn't get cleared.
     MutexAutoLock mon(mLock);
     if (m_channelListener) {
-      NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::m_channelListener",
-                                        m_channelListener.forget());
+      NS_ReleaseOnMainThread("nsImapProtocol::m_channelListener",
+                             m_channelListener.forget());
     }
   }
   m_channelInputStream = nullptr;
   m_channelOutputStream = nullptr;
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl;
   nsCOMPtr<nsIImapMailFolderSink> saveFolderSink;
 
@@ -1058,18 +1058,18 @@ void nsImapProtocol::ReleaseUrlState(boo
   }
   // Need to null this out whether we have an m_runningUrl or not
   m_imapMailFolderSink = nullptr;
 
   // we want to make sure the imap protocol's last reference to the url gets
   // released back on the UI thread. This ensures that the objects the imap url
   // hangs on to properly get released back on the UI thread.
   if (mailnewsurl) {
-    NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::m_runningUrl",
-                                      mailnewsurl.forget());
+    NS_ReleaseOnMainThread("nsImapProtocol::m_runningUrl",
+                           mailnewsurl.forget());
   }
   saveFolderSink = nullptr;
 }
 
 class nsImapThreadShutdownEvent : public mozilla::Runnable {
  public:
   explicit nsImapThreadShutdownEvent(nsIThread *thread)
       : mozilla::Runnable("nsImapThreadShutdownEvent"), mThread(thread) {}
@@ -1114,18 +1114,18 @@ NS_IMETHODIMP nsImapProtocol::Run() {
     // Cancel proxy on main thread.
     RefPtr<nsImapCancelProxy> cancelProxy =
         new nsImapCancelProxy(m_proxyRequest);
     NS_DispatchToMainThread(cancelProxy, NS_DISPATCH_SYNC);
     m_proxyRequest = nullptr;
   }
 
   if (m_runningUrl) {
-    NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::m_runningUrl",
-                                      m_runningUrl.forget());
+    NS_ReleaseOnMainThread("nsImapProtocol::m_runningUrl",
+                           m_runningUrl.forget());
   }
 
   // close streams via UI thread if it's not already done
   if (m_imapProtocolSink) m_imapProtocolSink->CloseStreams();
 
   m_imapMailFolderSink = nullptr;
   m_imapMessageSink = nullptr;
 
@@ -1133,18 +1133,17 @@ NS_IMETHODIMP nsImapProtocol::Run() {
   nsCOMPtr<nsIRunnable> ev = new nsImapThreadShutdownEvent(m_iThread);
   if (NS_FAILED(NS_DispatchToMainThread(ev)))
     NS_WARNING("Failed to dispatch nsImapThreadShutdownEvent");
   m_iThread = nullptr;
 
   // Release protocol object on the main thread to avoid destruction of 'this'
   // on the IMAP thread, which causes grief for weak references.
   nsCOMPtr<nsIImapProtocol> releaseOnMain(this);
-  NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::this",
-                                    releaseOnMain.forget());
+  NS_ReleaseOnMainThread("nsImapProtocol::this", releaseOnMain.forget());
   return NS_OK;
 }
 
 //
 // Must be called from UI thread only
 //
 NS_IMETHODIMP nsImapProtocol::CloseStreams() {
   // make sure that it is called by the UI thread
@@ -1859,18 +1858,17 @@ bool nsImapProtocol::ProcessCurrentURL()
           GetServerStateParser().LastCommandSuccessful() &&
               NS_SUCCEEDED(GetConnectionStatus()),
           copyState);
       if (NS_FAILED(rv))
         MOZ_LOG(IMAP, LogLevel::Info,
                 ("CopyNextStreamMessage failed: %" PRIx32,
                  static_cast<uint32_t>(rv)));
 
-      NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol, copyState",
-                                        copyState.forget());
+      NS_ReleaseOnMainThread("nsImapProtocol, copyState", copyState.forget());
     }
     // we might need this to stick around for IDLE support
     m_imapMailFolderSink = imapMailFolderSink;
     imapMailFolderSink = nullptr;
   } else
     MOZ_LOG(IMAP, LogLevel::Info, ("null imapMailFolderSink"));
 
   // now try queued urls, now that we've released this connection.
@@ -1923,18 +1921,18 @@ bool nsImapProtocol::RetryUrl() {
 
   // Hack for Bug 1586494.
   // (this is a workaround to try and prevent a specific crash, and
   // does nothing clarify the threading mess!)
   // RetryUrl() is only ever called from the imap thread.
   // Mockchannel dtor insists upon being run on the main thread.
   // So make sure we don't accidentally cause the mockchannel to die right now.
   if (saveMockChannel) {
-    NS_ReleaseOnMainThreadSystemGroup("nsImapProtocol::RetryUrl",
-                                      saveMockChannel.forget());
+    NS_ReleaseOnMainThread("nsImapProtocol::RetryUrl",
+                           saveMockChannel.forget());
   }
 
   return (m_imapServerSink != nullptr);  // we're running a url (the same url)
 }
 
 // ignoreBadAndNOResponses --> don't throw a error dialog if this command
 // results in a NO or Bad response from the server..in other words the command
 // is "exploratory" and we don't really care if it succeeds or fails.
--- a/mailnews/imap/src/nsSyncRunnableHelpers.cpp
+++ b/mailnews/imap/src/nsSyncRunnableHelpers.cpp
@@ -461,18 +461,18 @@ namespace mailnews {
 
 NS_IMPL_ISUPPORTS(OAuth2ThreadHelper, msgIOAuth2ModuleListener)
 
 OAuth2ThreadHelper::OAuth2ThreadHelper(nsIMsgIncomingServer *aServer)
     : mMonitor("OAuth thread lock"), mServer(aServer) {}
 
 OAuth2ThreadHelper::~OAuth2ThreadHelper() {
   if (mOAuth2Support) {
-    NS_ReleaseOnMainThreadSystemGroup("OAuth2ThreadHelper::mOAuth2Support",
-                                      mOAuth2Support.forget());
+    NS_ReleaseOnMainThread("OAuth2ThreadHelper::mOAuth2Support",
+                           mOAuth2Support.forget());
   }
 }
 
 bool OAuth2ThreadHelper::SupportsOAuth2() {
   // Acquire a lock early, before reading anything. Guarantees memory visibility
   // issues.
   MonitorAutoLock lockGuard(mMonitor);
 
--- a/mailnews/imap/src/nsSyncRunnableHelpers.h
+++ b/mailnews/imap/src/nsSyncRunnableHelpers.h
@@ -29,18 +29,18 @@ class StreamListenerProxy final : public
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
  private:
   ~StreamListenerProxy() {
-    NS_ReleaseOnMainThreadSystemGroup("StreamListenerProxy::mReceiver",
-                                      mReceiver.forget());
+    NS_ReleaseOnMainThread("StreamListenerProxy::mReceiver",
+                           mReceiver.forget());
   }
   nsCOMPtr<nsIStreamListener> mReceiver;
 };
 
 class ImapMailFolderSinkProxy final : public nsIImapMailFolderSink {
  public:
   explicit ImapMailFolderSinkProxy(nsIImapMailFolderSink* receiver)
       : mReceiver(receiver) {
@@ -48,18 +48,18 @@ class ImapMailFolderSinkProxy final : pu
         receiver, "Null receiver, crash now to get feedback instead of later");
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIMAPMAILFOLDERSINK
 
  private:
   ~ImapMailFolderSinkProxy() {
-    NS_ReleaseOnMainThreadSystemGroup("ImapMailFolderSinkProxy::mReceiver",
-                                      mReceiver.forget());
+    NS_ReleaseOnMainThread("ImapMailFolderSinkProxy::mReceiver",
+                           mReceiver.forget());
   }
   nsCOMPtr<nsIImapMailFolderSink> mReceiver;
 };
 
 class ImapServerSinkProxy final : public nsIImapServerSink {
  public:
   explicit ImapServerSinkProxy(nsIImapServerSink* receiver)
       : mReceiver(receiver) {
@@ -67,18 +67,18 @@ class ImapServerSinkProxy final : public
         receiver, "Null receiver, crash now to get feedback instead of later");
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIMAPSERVERSINK
 
  private:
   ~ImapServerSinkProxy() {
-    NS_ReleaseOnMainThreadSystemGroup("ImapServerSinkProxy::mReceiver",
-                                      mReceiver.forget());
+    NS_ReleaseOnMainThread("ImapServerSinkProxy::mReceiver",
+                           mReceiver.forget());
   }
   nsCOMPtr<nsIImapServerSink> mReceiver;
 };
 
 class ImapMessageSinkProxy final : public nsIImapMessageSink {
  public:
   explicit ImapMessageSinkProxy(nsIImapMessageSink* receiver)
       : mReceiver(receiver) {
@@ -86,18 +86,18 @@ class ImapMessageSinkProxy final : publi
         receiver, "Null receiver, crash now to get feedback instead of later");
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIMAPMESSAGESINK
 
  private:
   ~ImapMessageSinkProxy() {
-    NS_ReleaseOnMainThreadSystemGroup("ImapMessageSinkProxy::mReceiver",
-                                      mReceiver.forget());
+    NS_ReleaseOnMainThread("ImapMessageSinkProxy::mReceiver",
+                           mReceiver.forget());
   }
   nsCOMPtr<nsIImapMessageSink> mReceiver;
 };
 
 class ImapProtocolSinkProxy final : public nsIImapProtocolSink {
  public:
   explicit ImapProtocolSinkProxy(nsIImapProtocolSink* receiver)
       : mReceiver(receiver) {
@@ -105,18 +105,18 @@ class ImapProtocolSinkProxy final : publ
         receiver, "Null receiver, crash now to get feedback instead of later");
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIMAPPROTOCOLSINK
 
  private:
   ~ImapProtocolSinkProxy() {
-    NS_ReleaseOnMainThreadSystemGroup("ImapProtocolSinkProxy::mReceiver",
-                                      mReceiver.forget());
+    NS_ReleaseOnMainThread("ImapProtocolSinkProxy::mReceiver",
+                           mReceiver.forget());
   }
   nsCOMPtr<nsIImapProtocolSink> mReceiver;
 };
 
 class msgIOAuth2Module;
 class nsIMsgIncomingServer;
 
 namespace mozilla {