Bug 716289 - crash in nsCacheService::SearchCacheDevices
authorMichal Novotny <michal.novotny@gmail.com>
Thu, 12 Jan 2012 16:13:09 +0100
changeset 85571 d16983821d2f225d1946e5234fe3370a4dcf49ce
parent 85570 16d8c02193abb8d8636b70385ed657c45fc65831
child 85572 a0c02bb5fbb4343c063832485646d7385944ac99
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs716289
milestone12.0a1
Bug 716289 - crash in nsCacheService::SearchCacheDevices
netwerk/cache/nsCacheService.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1456,36 +1456,40 @@ nsCacheService::CreateDiskDevice()
         printf("###\n");
         printf("### mDiskDevice->Init() failed (0x%.8x)\n", rv);
         printf("###    - disabling disk cache for this session.\n");
         printf("###\n");
 #endif        
         mEnableDiskDevice = false;
         delete mDiskDevice;
         mDiskDevice = nsnull;
+        return rv;
     }
 
+    NS_ASSERTION(!mSmartSizeTimer, "Smartsize timer was already fired!");
+
     // Disk device is usually created during the startup. Delay smart size
     // calculation to avoid possible massive IO caused by eviction of entries
     // in case the new smart size is smaller than current cache usage.
-    if (!mSmartSizeTimer) {
-        mSmartSizeTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
-        if (NS_FAILED(rv))
-            return rv;
-
+    mSmartSizeTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
+    if (NS_SUCCEEDED(rv)) {
         rv = mSmartSizeTimer->InitWithCallback(new nsSetDiskSmartSizeCallback(),
                                                1000*60*3,
                                                nsITimer::TYPE_ONE_SHOT);
         if (NS_FAILED(rv)) {
             NS_WARNING("Failed to post smart size timer");
             mSmartSizeTimer = nsnull;
         }
+    } else {
+        NS_WARNING("Can't create smart size timer");
     }
-
-    return rv;
+    // Ignore state of the timer and return success since the purpose of the
+    // method (create the disk-device) has been fulfilled
+
+    return NS_OK;
 }
 
 nsresult
 nsCacheService::CreateOfflineDevice()
 {
     CACHE_LOG_ALWAYS(("Creating offline device"));
 
     if (!mInitialized)         return NS_ERROR_NOT_AVAILABLE;