From f7bdc9274aa6dc8efccc50d18dbb287225aa6c27 Mon Sep 17 00:00:00 2001 From: Mike Perry Date: Tue, 1 May 2012 15:02:03 -0700 Subject: [PATCH 17/17] 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 --- netwerk/cache/nsCacheService.cpp | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 015e49e..1ef0db1 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1415,10 +1415,21 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) return NS_OK; } - NS_IMETHODIMP nsCacheService::EvictEntries(nsCacheStoragePolicy storagePolicy) { - return EvictEntriesForClient(nsnull, storagePolicy); + NS_IMETHODIMP r; + r = EvictEntriesForClient(nsnull, 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; + gService->DoomActiveEntries(); + gService->ClearDoomList(); + (void) SyncWithCacheIOThread(); + } + return r; } NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget) -- 1.7.5.4