Commit 23e3f7be authored by Mike Perry's avatar Mike Perry
Browse files

Make nsICacheService.EvictEntries synchronous

This fixes a race condition that allows cache-based EverCookies to persist for
a brief time (on the order of minutes?) after cache clearing/"New Identity".

https://trac.torproject.org/projects/tor/ticket/5715
parent 4e34574f
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -1499,7 +1499,21 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor)

NS_IMETHODIMP nsCacheService::EvictEntries(nsCacheStoragePolicy storagePolicy)
{
    return  EvictEntriesForClient(nullptr, storagePolicy);
    NS_IMETHODIMP r;
    r = EvictEntriesForClient(nullptr, storagePolicy);

    // XXX: Bloody hack until we get this notifier in FF14.0:
    // https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsICacheListener#onCacheEntryDoomed%28%29
    if (storagePolicy == nsICache::STORE_ANYWHERE &&
            NS_IsMainThread() && gService && gService->mInitialized) {
        nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_EVICTENTRIESFORCLIENT));
        gService->mClearingEntries = true;
        gService->DoomActiveEntries(nullptr);
        gService->ClearDoomList();
        (void) SyncWithCacheIOThread();
        gService->mClearingEntries = false;
    }
    return r; 
}

NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget)