Bug 633146 - Remove unnecessary locking in nsCacheService::OpenCacheEntry; r=michal.novotny,bzbarsky
authorBjarne <bjarne@runitsoft.com>
Tue, 22 Mar 2011 15:17:13 -0400
changeset 63652 5df1de0e6a68d50beae2ef5f39bc415c85bcb772
parent 63651 4d8aaa21ac0412dfbfe8484d81f414ed4802c57e
child 63653 4203ab3adfde6258a261f5504a422667998c9999
push id19248
push usereakhgari@mozilla.com
push dateWed, 23 Mar 2011 23:19:35 +0000
treeherdermozilla-central@ab95ab9e389b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal.novotny, bzbarsky
bugs633146
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 633146 - Remove unnecessary locking in nsCacheService::OpenCacheEntry; r=michal.novotny,bzbarsky
netwerk/cache/nsCacheService.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1632,43 +1632,40 @@ nsCacheService::OpenCacheEntry(nsCacheSe
     if (result)
         *result = nsnull;
 
     if (!gService->mInitialized)
         return NS_ERROR_NOT_INITIALIZED;
 
     nsCacheRequest * request = nsnull;
 
-    nsCacheServiceAutoLock lock;
     nsresult rv = gService->CreateRequest(session,
                                           key,
                                           accessRequested,
                                           blockingMode,
                                           listener,
                                           &request);
     if (NS_FAILED(rv))  return rv;
 
     CACHE_LOG_DEBUG(("Created request %p\n", request));
 
     // Process the request on the background thread if we are on the main thread
     // and the the request is asynchronous
     if (NS_IsMainThread() && listener && gService->mCacheIOThread) {
         nsCOMPtr<nsIRunnable> ev =
             new nsProcessRequestEvent(request);
-        if (ev) {
-            rv = gService->mCacheIOThread->Dispatch(ev, NS_DISPATCH_NORMAL);
-        } else {
-            rv = NS_ERROR_OUT_OF_MEMORY;
-        }
+        rv = DispatchToCacheIOThread(ev);
 
         // delete request if we didn't post the event
         if (NS_FAILED(rv))
             delete request;
     }
     else {
+
+        nsCacheServiceAutoLock lock;
         rv = gService->ProcessRequest(request, PR_TRUE, result);
 
         // delete requests that have completed
         if (!(listener && (rv == NS_ERROR_CACHE_WAIT_FOR_VALIDATION)))
             delete request;
     }
 
     return rv;