Bug 1156771 - Part 1: Ensure that each channel uses a unique ID to compute its cache entry extension; r=michal

This makes sure that concurrent synthesized HTTP channels for the same
URL do not try to use the same cache entry accidentally.  We have so far
observed this issue as an intermittent test failure (see bug 1136780),
and it's hard to test this standalone, so enabling that test will serve
as an automated test for this patch as well.
This commit is contained in:
Ehsan Akhgari 2015-04-21 21:13:30 -04:00
Родитель c82004a974
Коммит ea261c2bb2
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -83,6 +83,10 @@ namespace mozilla { namespace net {
namespace {
// Monotonically increasing ID for generating unique cache entries per
// intercepted channel.
static uint64_t gNumIntercepted = 0;
// True if the local cache should be bypassed when processing a request.
#define BYPASS_LOCAL_CACHE(loadFlags) \
(loadFlags & (nsIRequest::LOAD_BYPASS_CACHE | \
@ -223,6 +227,7 @@ nsHttpChannel::nsHttpChannel()
, mRequestTime(0)
, mOfflineCacheLastModifiedTime(0)
, mInterceptCache(DO_NOT_INTERCEPT)
, mInterceptionID(gNumIntercepted++)
, mCachedContentIsValid(false)
, mCachedContentIsPartial(false)
, mCacheOnlyMetadata(false)
@ -2782,7 +2787,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
extension.Append(nsPrintfCString("%d", mPostID));
}
if (PossiblyIntercepted()) {
extension.Append('u');
extension.Append(nsPrintfCString("u%lld", mInterceptionID));
}
// If this channel should be intercepted, we do not open a cache entry for this channel

Просмотреть файл

@ -418,6 +418,8 @@ private:
MAYBE_INTERCEPT, // interception in progress, but can be cancelled
INTERCEPTED, // a synthesized response has been provided
} mInterceptCache;
// Unique ID of this channel for the interception purposes.
const uint64_t mInterceptionID;
bool PossiblyIntercepted() {
return mInterceptCache != DO_NOT_INTERCEPT;