Bug 1629204 - Avoid performing folder discovery during shutdown. r=mkmelin a=wsmwk
authorBen Campbell <benc@thunderbird.net>
Wed, 29 Apr 2020 13:34:08 +0300
changeset 36188 a6ffe45d0fc09fffa87fce6314f492a521883e52
parent 36187 e07c55e1519277df2cab5d92787c517256391354
child 36189 09d144bba4eea355f8b567ac5e11ecd12982786b
push id108
push userthunderbird@calypsoblue.org
push dateMon, 01 Jun 2020 19:26:03 +0000
treeherdercomm-esr68@2993d616ef7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1629204
Bug 1629204 - Avoid performing folder discovery during shutdown. r=mkmelin a=wsmwk
mailnews/base/util/nsMsgDBFolder.cpp
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -1305,19 +1305,22 @@ NS_IMETHODIMP nsMsgDBFolder::WriteToFold
                                         getter_AddRefs(cacheElement));
       if (NS_SUCCEEDED(rv) && cacheElement)
         rv = WriteToFolderCacheElem(cacheElement);
     }
   }
 
   if (!deep) return rv;
 
+  // NOTE: We must use mSubFolders directly, as GetSubFolders() can cause folder
+  // discovery (creation), which we don't need or want here. See bug 1629204.
   nsCOMPtr<nsISimpleEnumerator> enumerator;
-  rv = GetSubFolders(getter_AddRefs(enumerator));
-  if (NS_FAILED(rv)) return rv;
+  rv = NS_NewArrayEnumerator(getter_AddRefs(enumerator), mSubFolders,
+                             NS_GET_IID(nsIMsgFolder));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasMore;
   while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
     nsCOMPtr<nsISupports> item;
     enumerator->GetNext(getter_AddRefs(item));
 
     nsCOMPtr<nsIMsgFolder> msgFolder(do_QueryInterface(item));
     if (!msgFolder) continue;