Bug 1054813 - Add some missing MutexAutoLocks in nsZipReaderCache. r=mwu, a=lmandel
authorAaron Klotz <aklotz@mozilla.com>
Tue, 19 Aug 2014 12:11:03 -0600
changeset 209435 50590d1557c46d8ac2b68e99b18ef8c9b7fd315d
parent 209434 54949d681a1421e5bc081357cc07dd66053d719c
child 209436 61980c2f6177e6cdea0032860db032374857c020
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu, lmandel
bugs1054813
milestone32.0
Bug 1054813 - Add some missing MutexAutoLocks in nsZipReaderCache. r=mwu, a=lmandel
modules/libjar/nsJAR.cpp
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -1120,16 +1120,18 @@ nsZipReaderCache::GetInnerZip(nsIFile* z
                               nsIZipReader* *result)
 {
   NS_ENSURE_ARG_POINTER(zipFile);
 
   nsCOMPtr<nsIZipReader> outerZipReader;
   nsresult rv = GetZip(zipFile, getter_AddRefs(outerZipReader));
   NS_ENSURE_SUCCESS(rv, rv);
 
+  MutexAutoLock lock(mLock);
+
 #ifdef ZIP_CACHE_HIT_RATE
   mZipCacheLookups++;
 #endif
 
   nsAutoCString uri;
   rv = zipFile->GetNativePath(uri);
   if (NS_FAILED(rv)) return rv;
 
@@ -1280,16 +1282,17 @@ nsZipReaderCache::Observe(nsISupports *a
                           const char *aTopic,
                           const char16_t *aSomeData)
 {
   if (strcmp(aTopic, "memory-pressure") == 0) {
     MutexAutoLock lock(mLock);
     mZips.Enumerate(FindFlushableZip, nullptr);
   }
   else if (strcmp(aTopic, "chrome-flush-caches") == 0) {
+    MutexAutoLock lock(mLock);
     mZips.EnumerateRead(DropZipReaderCache, nullptr);
     mZips.Clear();
   }
   else if (strcmp(aTopic, "flush-cache-entry") == 0) {
     nsCOMPtr<nsIFile> file = do_QueryInterface(aSubject);
     if (!file)
       return NS_OK;