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 208351 50590d1557c4
parent 208350 54949d681a14
child 208352 61980c2f6177
push id3836
push userryanvm@gmail.com
push date2014-08-20 23:01 +0000
treeherdermozilla-beta@f5d4b16203aa [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;