Backed out changeset e75d5882e8b2 (bug 912465) for xpcshell crashes on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 19 Nov 2013 11:13:39 -0500
changeset 13295 933b83459851
parent 13294 e75d5882e8b2
child 13296 ffe30ba8cd1b
push id9662
push userryanvm@gmail.com
push dateTue, 19 Nov 2013 16:13:33 +0000
treeherdercomm-central@933b83459851 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs912465
backs oute75d5882e8b2
Backed out changeset e75d5882e8b2 (bug 912465) for xpcshell crashes on a CLOSED TREE.
mailnews/base/search/src/nsMsgFilterService.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/util/nsMsgMailNewsUrl.cpp
mailnews/local/src/nsPop3Protocol.cpp
--- a/mailnews/base/search/src/nsMsgFilterService.cpp
+++ b/mailnews/base/search/src/nsMsgFilterService.cpp
@@ -121,31 +121,33 @@ NS_IMETHODIMP nsMsgFilterService::CloseF
 }
 
 /* save without deleting */
 NS_IMETHODIMP  nsMsgFilterService::SaveFilterList(nsIMsgFilterList *filterList, nsIFile *filterFile)
 {
   NS_ENSURE_ARG_POINTER(filterFile);
   NS_ENSURE_ARG_POINTER(filterList);
 
+  nsCOMPtr<nsIOutputStream> out;
+  nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out),
+                                                filterFile, -1, 0600);
+  NS_ENSURE_SUCCESS(rv, rv);
+
   nsCOMPtr<nsIOutputStream> strm;
-  nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(strm),
-                                                filterFile, -1, 0600);
+  rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), out, 4096);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = filterList->SaveToFile(strm);
 
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(strm);
-  NS_ASSERTION(safeStream, "expected a safe output stream!");
-  if (safeStream) {
+  NS_ASSERTION(safeStream, "expected a safe output stream");
+  if (NS_SUCCEEDED(rv) && safeStream)
     rv = safeStream->Finish();
-    if (NS_FAILED(rv)) {
-      NS_WARNING("failed to save filter file! possible data loss");
-    }
-  }
+
+  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to save filter file");
   return rv;
 }
 
 NS_IMETHODIMP nsMsgFilterService::CancelFilterList(nsIMsgFilterList *filterList)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -3121,35 +3121,33 @@ NS_IMETHODIMP nsMsgAccountManager::SaveV
 {
   if (!m_virtualFoldersLoaded)
     return NS_OK;
 
   nsCOMPtr<nsIFile> file;
   GetVirtualFoldersFile(file);
 
   // Open a buffered, safe output stream
+  nsCOMPtr<nsIOutputStream> outStreamSink;
+  nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStreamSink),
+                                                file,
+                                                PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
+                                                0664);
+  NS_ENSURE_SUCCESS(rv, rv);
+
   nsCOMPtr<nsIOutputStream> outStream;
-  nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(outStream),
-                                                   file,
-                                                   PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
-                                                   0664);
+  rv = NS_NewBufferedOutputStream(getter_AddRefs(outStream), outStreamSink, 4096);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WriteLineToOutputStream("version=", "1", outStream);
   m_incomingServers.Enumerate(saveVirtualFolders, &outStream);
 
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(outStream, &rv);
-  NS_ASSERTION(safeStream, "expected a safe output stream!");
-  if (safeStream) {
-    rv = safeStream->Finish();
-    if (NS_FAILED(rv)) {
-      NS_WARNING("failed to save personal dictionary file! possible data loss");
-    }
-  }
-  return rv;
+  NS_ENSURE_SUCCESS(rv, rv);
+  return safeStream->Finish();
 }
 
 PLDHashOperator
 nsMsgAccountManager::saveVirtualFolders(nsCStringHashKey::KeyType key,
                                         nsCOMPtr<nsIMsgIncomingServer>& server,
                                         void *data)
 {
   if (server)
--- a/mailnews/base/util/nsMsgMailNewsUrl.cpp
+++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp
@@ -907,17 +907,19 @@ nsresult nsMsgSaveAsListener::SetupMsgWr
   // getting the outputstream.
   // Due to bug 328027, the nsSaveMsgListener created in
   // nsMessenger::SaveAs now opens the stream on the nsIFile
   // object, thus creating an empty file. Actual save operations for
   // IMAP and NNTP use this nsMsgSaveAsListener here, though, so we
   // have to close the stream before deleting the file, else data
   // would still be written happily into a now non-existing file.
   // (Windows doesn't care, btw, just unixoids do...)
-  nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(m_outputStream),
+  aFile->Remove(false);
+
+  nsresult rv = MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream),
                                                aFile, -1, 0666);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (m_outputStream && addDummyEnvelope)
   {
     nsAutoCString result;
     uint32_t writeCount;
 
@@ -931,25 +933,17 @@ nsresult nsMsgSaveAsListener::SetupMsgWr
     m_outputStream->Write(result.get(), result.Length(), &writeCount);
 
     result = "X-Mozilla-Status: 0001";
     result += MSG_LINEBREAK;
     result += "X-Mozilla-Status2: 00000000";
     result += MSG_LINEBREAK;
     m_outputStream->Write(result.get(), result.Length(), &writeCount);
   }
-  NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(m_outputStream);
-  NS_ASSERTION(safeStream, "expected a safe output stream!");
-  if (safeStream) {
-    rv = safeStream->Finish();
-    if (NS_FAILED(rv)) {
-      NS_WARNING("failed to save msg file! possible data loss");
-    }
-  }
+
   return rv;
 }
 
 
 NS_IMETHODIMP nsMsgMailNewsUrl::GetSaveAsListener(bool addDummyEnvelope, 
                                                   nsIFile *aFile, nsIStreamListener **aSaveListener)
 {
   NS_ENSURE_ARG_POINTER(aSaveListener);
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -348,23 +348,17 @@ net_pop3_write_state(Pop3UidlHost* host,
       fileOutputStream->Write(host->host, strlen(host->host), &numBytesWritten);
       fileOutputStream->Write(" ", 1, &numBytesWritten);
       fileOutputStream->Write(host->user, strlen(host->user), &numBytesWritten);
       fileOutputStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &numBytesWritten);
       PL_HashTableEnumerateEntries(host->hash, net_pop3_write_mapper, (void *)fileOutputStream);
     }
   }
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(fileOutputStream);
-  NS_ASSERTION(safeStream, "expected a safe output stream!");
-  if (safeStream) {
-    rv = safeStream->Finish();
-    if (NS_FAILED(rv)) {
-      NS_WARNING("failed to save pop state! possible data loss");
-    }
-  }
+  safeStream->Finish();
 }
 
 static void
 net_pop3_free_state(Pop3UidlHost* host)
 {
   Pop3UidlHost* h;
   while (host)
   {