Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@ -91,7 +91,7 @@ namespace System.Web {
// Overload used only for deducing ETW parameters; use the public entry point instead.
//
// !! WARNING !!
// The logic in RequestEnteredAspNetPipelineImpl must be kept in [....] with these parameters, otherwise
// The logic in RequestEnteredAspNetPipelineImpl must be kept in sync with these parameters, otherwise
// type safety violations could occur.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "ETW looks at this method using reflection.")]
[Event((int)Events.RequestEnteredAspNetPipeline, Level = EventLevel.Informational, Task = (EventTask)Tasks.Request, Opcode = EventOpcode.Send, Version = 1)]
@ -118,7 +118,7 @@ namespace System.Web {
fixed (char* pHttpVerb = httpVerb) {
// !! WARNING !!
// This logic must be kept in [....] with the ETW-deduced parameters in RequestStarted,
// This logic must be kept in sync with the ETW-deduced parameters in RequestStarted,
// otherwise type safety violations could occur.
const int EVENTDATA_COUNT = 3;
EventData* pEventData = stackalloc EventData[EVENTDATA_COUNT];
@ -145,7 +145,7 @@ namespace System.Web {
// Event attribute, but this causes a dependency between System.Web and mscorlib that breaks servicing.
//
// !! WARNING !!
// The logic in RequestStartedImpl must be kept in [....] with these parameters, otherwise
// The logic in RequestStartedImpl must be kept in sync with these parameters, otherwise
// type safety violations could occur.
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "ETW looks at this method using reflection.")]
[Event((int)Events.RequestStarted, Level = EventLevel.Informational, Task = (EventTask)Tasks.Request, Opcode = EventOpcode.Start, Version = 1)]

View File

@ -26,10 +26,6 @@ namespace System.Web.Caching {
using System.Runtime.Caching;
#endif
internal interface ICacheDependencyChanged {
void DependencyChanged(Object sender, EventArgs e);
}
/// <devdoc>
/// <para>The <see langword='CacheDependency'/> class tracks cache dependencies, which can be files,
@ -50,7 +46,7 @@ namespace System.Web.Caching {
string _uniqueID; // used by HttpCachePolicy for the ETag
object _depFileInfos; // files to monitor for changes, either a DepFileInfo or array of DepFileInfos
object _entries; // cache entries we are dependent on, either a string or array of strings
ICacheDependencyChanged _objNotify; // Associated object to notify when a change occurs
Action<Object, EventArgs> _objNotify; // Associated object to notify when a change occurs
SafeBitVector32 _bits; // status bits for ready, used, changed, disposed
DateTime _utcLastModified; // Time of last modified item
#if USE_MEMORY_CACHE
@ -59,7 +55,7 @@ namespace System.Web.Caching {
#endif
static readonly string[] s_stringsEmpty;
static readonly CacheEntry[] s_entriesEmpty;
static readonly DepCacheInfo[] s_entriesEmpty;
static readonly CacheDependency s_dependencyEmpty;
static readonly DepFileInfo[] s_depFileInfosEmpty;
@ -78,9 +74,14 @@ namespace System.Web.Caching {
internal FileAttributesData _fad;
}
internal class DepCacheInfo {
internal CacheStoreProvider _cacheStore;
internal string _key;
}
static CacheDependency() {
s_stringsEmpty = new string[0];
s_entriesEmpty = new CacheEntry[0];
s_entriesEmpty = new DepCacheInfo[0];
s_dependencyEmpty = new CacheDependency(0);
s_depFileInfosEmpty = new DepFileInfo[0];
}
@ -205,7 +206,7 @@ namespace System.Web.Caching {
void InitForMemoryCache(bool isPublic, string[] filenamesArg, string[] cachekeysArg, CacheDependency dependency, DateTime utcStart) {
bool dispose = true;
try {
MemCache memCache = HttpRuntime.CacheInternal as MemCache;
MemCache memCache = HttpRuntime.InternalCache as MemCache;
_bits = new SafeBitVector32(0);
_utcLastModified = DateTime.MinValue;
IList<String> files = filenamesArg;
@ -308,9 +309,9 @@ namespace System.Web.Caching {
}
#endif
DepFileInfo[] depFileInfos = s_depFileInfosEmpty;
CacheEntry[] depEntries = s_entriesEmpty;
DepCacheInfo[] depEntries = s_entriesEmpty;
string [] filenames, cachekeys;
CacheInternal cacheInternal;
CacheStoreProvider cache;
_bits = new SafeBitVector32(0);
@ -420,13 +421,13 @@ namespace System.Web.Caching {
// copy cache entries
if (d_entries != null) {
if (d_entries is CacheEntry) {
depEntries = new CacheEntry[1] {(CacheEntry) (d_entries)};
if (d_entries is DepCacheInfo) {
depEntries = new DepCacheInfo[1] { (DepCacheInfo)(d_entries) };
}
else {
depEntries = (CacheEntry[]) (d_entries);
depEntries = (DepCacheInfo[])(d_entries);
// verify that the object was fully constructed
foreach (CacheEntry entry in depEntries) {
foreach (DepCacheInfo entry in depEntries) {
if (entry == null) {
_bits[CHANGED] = true;
// There is nothing to dispose because we haven't started
@ -501,41 +502,32 @@ namespace System.Web.Caching {
// Monitor other cache entries for changes
int lenMyEntries = depEntries.Length + cachekeys.Length;
DateTime lastUpdated;
if (lenMyEntries > 0 && !_bits[CHANGED]) {
CacheEntry[] myEntries = new CacheEntry[lenMyEntries];
DepCacheInfo[] myEntries = new DepCacheInfo[lenMyEntries];
// Monitor entries from the existing cache dependency
int i = 0;
foreach (CacheEntry entry in depEntries) {
entry.AddCacheDependencyNotify(this);
foreach (DepCacheInfo entry in depEntries) {
entry._cacheStore.AddDependent(entry._key, this, out lastUpdated);
myEntries[i++] = entry;
}
// Monitor new entries specified for this depenedency
// Entries must be added to cache, and created before the startTime
cacheInternal = HttpRuntime.CacheInternal;
cache = isPublic ? HttpRuntime.Cache.ObjectCache : HttpRuntime.Cache.InternalCache;
foreach (string k in cachekeys) {
CacheEntry entry = (CacheEntry) cacheInternal.DoGet(isPublic, k, CacheGetOptions.ReturnCacheEntry);
if (entry != null) {
entry.AddCacheDependencyNotify(this);
myEntries[i++] = entry;
if (cache.AddDependent(k, this, out lastUpdated)) {
myEntries[i++] = new DepCacheInfo() { _cacheStore = cache, _key = k };
if (entry.UtcCreated > _utcLastModified) {
_utcLastModified = entry.UtcCreated;
if (lastUpdated > _utcLastModified) {
_utcLastModified = lastUpdated;
}
if ( entry.State != CacheEntry.EntryState.AddedToCache ||
entry.UtcCreated > utcStart) {
if (lastUpdated > utcStart) { // Cache item has been updated since start, consider changed
#if DBG
if (entry.State != CacheEntry.EntryState.AddedToCache) {
Debug.Trace("CacheDependencyInit", "Entry is not in cache, considered changed:" + k);
}
else {
Debug.Trace("CacheDependencyInit", "Changes occurred to entry since start time:" + k);
}
Debug.Trace("CacheDependencyInit", "Changes occurred to entry since start time:" + k);
#endif
_bits[CHANGED] = true;
break;
}
@ -583,7 +575,7 @@ namespace System.Web.Caching {
// Set this bit just in case our derived ctor forgot to call FinishInit()
_bits[DERIVED_INIT] = true;
if (Use()) {
if (TakeOwnership()) {
// Do the dispose only if the cache has not already used us
DisposeInternal();
}
@ -660,17 +652,17 @@ namespace System.Web.Caching {
// stop monitoring cache items
if (l_entries != null) {
CacheEntry oneEntry = l_entries as CacheEntry;
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
if (oneEntry != null) {
oneEntry.RemoveCacheDependencyNotify(this);
oneEntry._cacheStore.RemoveDependent(oneEntry._key, this);
}
else {
CacheEntry[] entries = (CacheEntry[]) l_entries;
foreach (CacheEntry entry in entries) {
DepCacheInfo[] entries = (DepCacheInfo[])l_entries;
foreach (DepCacheInfo entry in entries) {
// ensure that we handle partially contructed
// objects by checking entry for null
if (entry != null) {
entry.RemoveCacheDependencyNotify(this);
entry._cacheStore.RemoveDependent(entry._key, this);
}
}
}
@ -686,8 +678,10 @@ namespace System.Web.Caching {
#endif
}
// allow the first user to declare ownership
internal bool Use() {
/// <devdoc>
/// <para>Allow the first user to declare exclusive ownership of this dependency.</para>
/// </devdoc>
public bool TakeOwnership() {
return _bits.ChangeValue(USED, true);
}
@ -706,22 +700,38 @@ namespace System.Web.Caching {
}
}
protected void SetUtcLastModified(DateTime utcLastModified) {
_utcLastModified = utcLastModified;
}
//
// Add/remove an NotifyDependencyChanged notification.
//
internal void SetCacheDependencyChanged(ICacheDependencyChanged objNotify) {
public void KeepDependenciesAlive() {
if (_entries != null) {
// update the last access time of every cache item that depends on this dependency
DepCacheInfo oneEntry = _entries as DepCacheInfo;
if (oneEntry != null) {
oneEntry._cacheStore.Get(oneEntry._key);
return;
}
foreach (DepCacheInfo entry in (DepCacheInfo[])_entries) {
if (entry != null) {
object item = entry._cacheStore.Get(entry._key);
}
}
}
}
/// <devdoc>
/// <para>Add an Action to handle notifying interested party in changes to this dependency.</para>
/// </devdoc>
public void SetCacheDependencyChanged(Action<Object, EventArgs> dependencyChangedAction) {
Debug.Assert(_objNotify == null, "_objNotify == null");
// Set this bit just in case our derived ctor forgot to call FinishInit()
_bits[DERIVED_INIT] = true;
if (!_bits[BASE_DISPOSED]) {
_objNotify = objNotify;
_objNotify = dependencyChangedAction;
}
}
@ -768,23 +778,23 @@ namespace System.Web.Caching {
// get unique id from cache entries
l_entries = _entries;
if (l_entries != null) {
CacheEntry oneEntry = l_entries as CacheEntry;
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
if (oneEntry != null) {
if (sb == null)
sb = new StringBuilder();
sb.Append(oneEntry.Key);
sb.Append(oneEntry.UtcCreated.Ticks.ToString(CultureInfo.InvariantCulture));
sb.Append(oneEntry._key);
sb.Append(oneEntry.GetHashCode().ToString(CultureInfo.InvariantCulture));
}
else {
CacheEntry[] entries = (CacheEntry[]) l_entries;
foreach (CacheEntry entry in entries) {
DepCacheInfo[] entries = (DepCacheInfo[])l_entries;
foreach (DepCacheInfo entry in entries) {
// ensure that we handle partially contructed
// objects by checking entry for null
if (entry != null) {
if (sb == null)
sb = new StringBuilder();
sb.Append(entry.Key);
sb.Append(entry.UtcCreated.Ticks.ToString(CultureInfo.InvariantCulture));
sb.Append(entry._key);
sb.Append(entry.GetHashCode().ToString(CultureInfo.InvariantCulture));
}
}
}
@ -805,24 +815,6 @@ namespace System.Web.Caching {
return _uniqueID;
}
//
// Return the cacheEntries monitored by this dependency
//
internal CacheEntry[] CacheEntries {
get {
if (_entries == null) {
return null;
}
CacheEntry oneEntry = _entries as CacheEntry;
if (oneEntry != null) {
return new CacheEntry[1] {oneEntry};
}
return (CacheEntry[]) _entries;
}
}
//
// This object has changed, so fire the NotifyDependencyChanged event.
// We only allow this event to be fired once.
@ -832,20 +824,20 @@ namespace System.Web.Caching {
if (_bits.ChangeValue(CHANGED, true)) {
_utcLastModified = DateTime.UtcNow;
ICacheDependencyChanged objNotify = _objNotify;
if (objNotify != null && !_bits[BASE_DISPOSED]) {
Action<Object, EventArgs> action = _objNotify as Action<Object, EventArgs>;
if (action != null && !_bits[BASE_DISPOSED]) {
Debug.Trace("CacheDependencyNotifyDependencyChanged", "change occurred");
objNotify.DependencyChanged(sender, e);
action(sender, e);
}
DisposeInternal();
}
}
//
// ItemRemoved is called when a cache entry we are monitoring has been removed.
//
internal void ItemRemoved() {
/// <devdoc>
/// <para>ItemRemoved should be called when an ICacheEntry we are monitoring has been removed.</para>
/// </devdoc>
public void ItemRemoved() {
NotifyDependencyChanged(this, EventArgs.Empty);
}
@ -880,12 +872,12 @@ namespace System.Web.Caching {
// Check and see if we are dependent on any cache entries
l_entries = _entries;
if (l_entries != null) {
CacheEntry oneEntry = l_entries as CacheEntry;
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
if (oneEntry != null) {
return false;
}
else {
CacheEntry[] entries = (CacheEntry[]) l_entries;
DepCacheInfo[] entries = (DepCacheInfo[]) l_entries;
if (entries != null && entries.Length > 0) {
return false;
}
@ -952,7 +944,7 @@ namespace System.Web.Caching {
}
}
public sealed class AggregateCacheDependency : CacheDependency, ICacheDependencyChanged {
public sealed class AggregateCacheDependency : CacheDependency {
ArrayList _dependencies;
bool _disposed;
@ -979,10 +971,9 @@ namespace System.Web.Caching {
throw new ArgumentNullException("dependencies");
}
if (!d.Use()) {
if (!d.TakeOwnership()) {
throw new InvalidOperationException(SR.GetString(SR.Cache_dependency_used_more_that_once));
}
}
} }
// add dependencies, and check if any have changed
bool hasChanged = false;
@ -995,7 +986,9 @@ namespace System.Web.Caching {
_dependencies.AddRange(dependencies);
foreach (CacheDependency d in dependencies) {
d.SetCacheDependencyChanged(this);
d.SetCacheDependencyChanged((Object sender, EventArgs args) => {
DependencyChanged(sender, args);
});
if (d.UtcLastModified > utcLastModified) {
utcLastModified = d.UtcLastModified;
@ -1041,7 +1034,7 @@ namespace System.Web.Caching {
// Forward call from the aggregate to the CacheEntry
/// <internalonly/>
void ICacheDependencyChanged.DependencyChanged(Object sender, EventArgs e) {
void DependencyChanged(Object sender, EventArgs e) {
NotifyDependencyChanged(sender, e);
}
@ -1122,7 +1115,7 @@ namespace System.Web.Caching {
return true;
}
/// <summary>
/// This method will return only the file dependencies from this dependency
/// </summary>

View File

@ -50,8 +50,8 @@ namespace System.Web.Caching {
#endif
}
internal String Key {
get {return _key;}
internal String Key {
get { return _key; }
}
internal bool IsOutputCache {
@ -81,9 +81,7 @@ namespace System.Web.Caching {
* An entry in the cache.
* Overhead is 68 bytes + object header.
*/
internal sealed class CacheEntry : CacheKey, ICacheDependencyChanged {
static readonly DateTime NoAbsoluteExpiration = DateTime.MaxValue;
static readonly TimeSpan NoSlidingExpiration = TimeSpan.Zero;
internal sealed class CacheEntry : CacheKey {
const CacheItemPriority CacheItemPriorityMin = CacheItemPriority.Low;
const CacheItemPriority CacheItemPriorityMax = CacheItemPriority.NotRemovable;
static readonly TimeSpan OneYear = new TimeSpan(365, 0, 0, 0);
@ -116,12 +114,13 @@ namespace System.Web.Caching {
byte _usageBucket; /* index of the usage list (== priority-1) */
UsageEntryRef _usageEntryRef; /* ref into the usage list */
DateTime _utcLastUpdate; /* time we last updated usage */
CacheInternal _cache;
// dependencies
CacheDependency _dependency; /* dependencies this item has */
object _onRemovedTargets; /* targets of OnRemove notification */
/*
/*
* ctor.
*/
@ -130,10 +129,11 @@ namespace System.Web.Caching {
Object value,
CacheDependency dependency,
CacheItemRemovedCallback onRemovedHandler,
DateTime utcAbsoluteExpiration,
DateTime utcAbsoluteExpiration,
TimeSpan slidingExpiration,
CacheItemPriority priority,
bool isPublic) :
bool isPublic,
CacheInternal cache) :
base(key, isPublic) {
@ -176,6 +176,8 @@ namespace System.Web.Caching {
else {
_usageBucket = (byte) (priority - 1);
}
_cache = cache;
}
internal Object Value {
@ -248,21 +250,23 @@ namespace System.Web.Caching {
// need to protect against the item being closed
CacheDependency dependency = _dependency;
if (dependency != null && State == EntryState.AddedToCache) {
if (!dependency.Use()) {
if (!dependency.TakeOwnership()) {
throw new InvalidOperationException(
SR.GetString(SR.Cache_dependency_used_more_that_once));
}
dependency.SetCacheDependencyChanged(this);
dependency.SetCacheDependencyChanged((Object sender, EventArgs args) => {
DependencyChanged(sender, args);
});
}
}
/*
* The entry has changed, so remove ourselves from the cache.
*/
void ICacheDependencyChanged.DependencyChanged(Object sender, EventArgs e) {
void DependencyChanged(Object sender, EventArgs e) {
if (State == EntryState.AddedToCache) {
HttpRuntime.CacheInternal.Remove(this, CacheItemRemovedReason.DependencyChanged);
_cache.Remove(this, CacheItemRemovedReason.DependencyChanged);
}
}
@ -369,7 +373,7 @@ namespace System.Web.Caching {
}
#endif
internal void AddCacheDependencyNotify(CacheDependency dependency) {
internal void AddDependent(CacheDependency dependency) {
lock (this) {
if (_onRemovedTargets == null) {
_onRemovedTargets = dependency;
@ -387,16 +391,14 @@ namespace System.Web.Caching {
}
}
internal void RemoveCacheDependencyNotify(CacheDependency dependency) {
internal void RemoveDependent(CacheDependency dependency) {
lock (this) {
if (_onRemovedTargets != null) {
if (_onRemovedTargets == dependency) {
_onRemovedTargets = null;
}
else {
// We assume the dependency must exist, so we don't need
// to test for a cast.
Hashtable h = (Hashtable) _onRemovedTargets;
else if (_onRemovedTargets is Hashtable) {
Hashtable h = (Hashtable)_onRemovedTargets;
h.Remove(dependency);
if (h.Count == 0) {
_onRemovedTargets = null;

View File

@ -282,29 +282,17 @@ namespace System.Web.Caching {
//
// helpers for accessing CacheInternal
// helpers for accessing InternalCache
//
// add CachedVary
private static CachedVary UtcAdd(String key, CachedVary cachedVary) {
return (CachedVary) HttpRuntime.CacheInternal.UtcAdd(key,
cachedVary,
null /*dependencies*/,
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.Normal,
null /*callback*/);
return (CachedVary) HttpRuntime.Cache.InternalCache.Add(key, cachedVary, null);
}
// add ControlCachedVary
private static ControlCachedVary UtcAdd(String key, ControlCachedVary cachedVary) {
return (ControlCachedVary) HttpRuntime.CacheInternal.UtcAdd(key,
cachedVary,
null /*dependencies*/,
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.Normal,
null /*callback*/);
return (ControlCachedVary) HttpRuntime.Cache.InternalCache.Add(key, cachedVary, null);
}
private static bool IsSubstBlockSerializable(HttpRawResponse rawResponse) {
@ -391,7 +379,7 @@ namespace System.Web.Caching {
String kernelCacheUrl = cachedRawResponse._kernelCacheUrl;
// if it is kernel cached, the url will be non-null.
// if the entry was re-inserted, don't remove kernel entry since it will be updated
if (kernelCacheUrl != null && HttpRuntime.CacheInternal.Get(key) == null) {
if (kernelCacheUrl != null && HttpRuntime.Cache.InternalCache.Get(key) == null) {
// invalidate kernel cache entry
if (HttpRuntime.UseIntegratedPipeline) {
UnsafeIISMethods.MgdFlushKernelCache(kernelCacheUrl);
@ -462,7 +450,7 @@ namespace System.Web.Caching {
}
// is the file dependency already in the in-memory cache?
if (HttpRuntime.CacheInternal.Get(depKey) != null) {
if (HttpRuntime.Cache.InternalCache.Get(depKey) != null) {
#if DBG
Debug.Trace("OutputCache", "HasDependencyChanged(" + depKey + ", ..., " + oceKey + ", ...) --> false");
#endif
@ -480,9 +468,10 @@ namespace System.Web.Caching {
// have the file dependencies changed?
if (String.Compare(dep.GetUniqueID(), 0, depKey, idStartIndex, idLength, StringComparison.Ordinal) == 0) {
// file dependencies have not changed--cache them with callback to remove OutputCacheEntry if they change
HttpRuntime.CacheInternal.UtcInsert(depKey, new DependencyCacheEntry(oceKey, kernelKey, providerName), dep,
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, callback);
HttpRuntime.Cache.InternalCache.Insert(depKey, new DependencyCacheEntry(oceKey, kernelKey, providerName), new CacheInsertOptions() {
Dependencies = dep,
OnRemovedCallback = callback
});
#if DBG
Debug.Trace("OutputCache", "HasDependencyChanged(" + depKey + ", ..., " + oceKey + ", ...) --> false, DEPENDENCY RE-INSERTED");
#endif
@ -545,7 +534,7 @@ namespace System.Web.Caching {
}
}
if (result == null) {
result = HttpRuntime.CacheInternal.Get(key);
result = HttpRuntime.Cache.InternalCache.Get(key);
#if DBG
string typeName = (result != null) ? result.GetType().Name : "null";
Debug.Trace("OutputCache", "Get(" + key + ") --> " + typeName + ", CacheInternal");
@ -580,7 +569,7 @@ namespace System.Web.Caching {
}
if (result == null) {
result = HttpRuntime.CacheInternal.Get(key);
result = HttpRuntime.Cache.InternalCache.Get(key);
#if DBG
string typeName = (result != null) ? result.GetType().Name : "null";
Debug.Trace("OutputCache", "GetFragment(" + key + "," + providerName + ") --> " + typeName + ", CacheInternal");
@ -601,7 +590,7 @@ namespace System.Web.Caching {
// If the context is null, then we don't know which
// provider and we have to check all.
HttpRuntime.CacheInternal.Remove(key);
HttpRuntime.Cache.InternalCache.Remove(key);
if (context == null) {
// remove from all providers since we don't know which one it's in.
@ -654,7 +643,7 @@ namespace System.Web.Caching {
if (provider != null) {
provider.Remove(key);
}
HttpRuntime.CacheInternal.Remove(key);
HttpRuntime.Cache.InternalCache.Remove(key);
#if DBG
Debug.Trace("OutputCache", "RemoveFragment(" + key + "," + providerName + ")");
#endif
@ -708,7 +697,7 @@ namespace System.Web.Caching {
if (!cachedVary.Equals(cachedVaryInCache)) {
// overwrite existing cached vary
if (!useProvider) {
HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
HttpRuntime.Cache.InternalCache.Insert(cachedVaryKey, cachedVary, null);
}
else {
provider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
@ -733,11 +722,11 @@ namespace System.Web.Caching {
// Now insert into the cache (use cache provider if possible, otherwise use internal cache)
if (!useProvider) {
HttpRuntime.CacheInternal.UtcInsert(fragmentKey, fragment,
dependencies,
absExp, slidingExp,
CacheItemPriority.Normal,
null);
HttpRuntime.Cache.InternalCache.Insert(fragmentKey, fragment, new CacheInsertOptions() {
Dependencies = dependencies,
AbsoluteExpiration = absExp,
SlidingExpiration = slidingExp
});
}
else {
string depKey = null;
@ -749,10 +738,12 @@ namespace System.Web.Caching {
provider.Set(fragmentKey, fragment, absExp);
if (dependencies != null) {
// use Add and dispose dependencies if there's already one in the cache
Object d = HttpRuntime.CacheInternal.UtcAdd(depKey, new DependencyCacheEntry(fragmentKey, null, provider.Name),
dependencies,
absExp, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, s_dependencyRemovedCallbackForFragment);
Object d = HttpRuntime.Cache.InternalCache.Add(depKey, new DependencyCacheEntry(fragmentKey, null, provider.Name),
new CacheInsertOptions() {
Dependencies = dependencies,
AbsoluteExpiration = absExp,
OnRemovedCallback = s_dependencyRemovedCallbackForFragment
});
if (d != null) {
dependencies.Dispose();
}
@ -768,7 +759,7 @@ namespace System.Web.Caching {
+ fragmentKey + ", PartialCachingCacheEntry, ...) -->"
+ providerUsed);
#endif
}
}
// insert cached vary or output cache entry
internal static void InsertResponse(String cachedVaryKey, CachedVary cachedVary,
@ -820,7 +811,7 @@ namespace System.Web.Caching {
if (cachedVaryInCache != null) {
if (!cachedVary.Equals(cachedVaryInCache)) {
if (!useProvider) {
HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
HttpRuntime.Cache.InternalCache.Insert(cachedVaryKey, cachedVary, null);
}
else {
provider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
@ -845,11 +836,12 @@ namespace System.Web.Caching {
// Now insert into the cache (use cache provider if possible, otherwise use internal cache)
if (!useProvider) {
HttpRuntime.CacheInternal.UtcInsert(rawResponseKey, rawResponse,
dependencies,
absExp, slidingExp,
CacheItemPriority.Normal,
s_entryRemovedCallback);
HttpRuntime.Cache.InternalCache.Insert(rawResponseKey, rawResponse, new CacheInsertOptions() {
Dependencies = dependencies,
AbsoluteExpiration = absExp,
SlidingExpiration = slidingExp,
OnRemovedCallback = s_entryRemovedCallback
});
IncrementCount();
@ -867,10 +859,12 @@ namespace System.Web.Caching {
provider.Set(rawResponseKey, oce, absExp);
if (dependencies != null) {
// use Add and dispose dependencies if there's already one in the cache
Object d = HttpRuntime.CacheInternal.UtcAdd(depKey, new DependencyCacheEntry(rawResponseKey, oce.KernelCacheUrl, provider.Name),
dependencies,
absExp, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, s_dependencyRemovedCallback);
Object d = HttpRuntime.Cache.InternalCache.Add(depKey, new DependencyCacheEntry(rawResponseKey, oce.KernelCacheUrl, provider.Name),
new CacheInsertOptions() {
Dependencies = dependencies,
AbsoluteExpiration = absExp,
OnRemovedCallback = s_dependencyRemovedCallbackForFragment
});
if (d != null) {
dependencies.Dispose();
}

View File

@ -69,7 +69,7 @@ namespace System.Web.Caching {
{
Debug.Trace("SqlCacheDependency",
"Depend on key=" + GetDependKey(databaseEntryName, tableName) + "; value=" +
HttpRuntime.CacheInternal[GetDependKey(databaseEntryName, tableName)]);
HttpRuntime.Cache.InternalCache.Get(GetDependKey(databaseEntryName, tableName)));
// Permission checking is done in GetDependKey()
@ -77,7 +77,7 @@ namespace System.Web.Caching {
_sql7DepInfo._database = databaseEntryName;
_sql7DepInfo._table = tableName;
object o = HttpRuntime.CacheInternal[GetDependKey(databaseEntryName, tableName)];
object o = HttpRuntime.Cache.InternalCache.Get(GetDependKey(databaseEntryName, tableName));
if (o == null) {
// If the cache entry can't be found, this cache dependency will be set to CHANGED already.
_sql7ChangeId = -1;
@ -756,7 +756,7 @@ namespace System.Web.Caching {
SqlCommand sqlCmd = null;
int changeId;
string tableName;
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache;
string monitorKey;
object obj;
bool notifEnabled = false;
@ -864,33 +864,28 @@ namespace System.Web.Caching {
"Database=" + dbState._database+ "; tableName=" + tableName + "; changeId=" + changeId);
monitorKey = GetMoniterKey(dbState._database, tableName);
obj = cacheInternal[monitorKey];
obj = cacheInternal.Get(monitorKey);
if (obj == null) {
Debug.Assert(!dbState._tables.ContainsKey(tableName),
"DatabaseNotifStae._tables and internal cache keys should be in-[....]");
"DatabaseNotifStae._tables and internal cache keys should be in-sync");
Debug.Trace("SqlCacheDependencyManagerPolling",
"Add Database=" + dbState._database+ "; tableName=" + tableName + "; changeId=" + changeId);
cacheInternal.UtcAdd(monitorKey, changeId, null,
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, null);
cacheInternal.Add(monitorKey, changeId, new CacheInsertOptions() { Priority = CacheItemPriority.NotRemovable });
dbState._tables.Add(tableName, null);
}
else if (changeId != (int)obj) {
Debug.Assert(dbState._tables.ContainsKey(tableName),
"DatabaseNotifStae._tables and internal cache keys should be in-[....]");
"DatabaseNotifStae._tables and internal cache keys should be in-sync");
Debug.Trace("SqlCacheDependencyManagerPolling",
"Change Database=" + dbState._database+ "; tableName=" + tableName + "; old=" + (int)obj + "; new=" + changeId);
// ChangeId is different. It means some table changes have happened.
// Update local cache value
cacheInternal.UtcInsert(monitorKey, changeId, null,
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, null);
cacheInternal.Insert(monitorKey, changeId, new CacheInsertOptions() { Priority = CacheItemPriority.NotRemovable });
}
originalTables.Remove(tableName);
@ -1001,8 +996,8 @@ namespace System.Web.Caching {
// for this table has successfully completed
Debug.Trace("SqlCacheDependencyManagerCheck",
"Check is called. Database=" + database+ "; table=" + table);
if (HttpRuntime.CacheInternal[GetMoniterKey(database, table)] != null) {
if (HttpRuntime.Cache.InternalCache.Get(GetMoniterKey(database, table)) != null) {
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -196,7 +196,7 @@ namespace System.Web {
// the filesystem.
//
string key = CreateKey(configPath);
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache;
CachedPathData data = (CachedPathData) cacheInternal.Get(key);
// if found, return the data
@ -272,9 +272,12 @@ namespace System.Web {
try {
}
finally {
data = (CachedPathData) cacheInternal.UtcAdd(key, dataAdd, dependency,
Cache.NoAbsoluteExpiration, slidingExpiration,
priority, s_callback);
data = (CachedPathData)cacheInternal.Add(key, dataAdd, new CacheInsertOptions() {
Dependencies = dependency,
SlidingExpiration = slidingExpiration,
Priority = priority,
OnRemovedCallback = s_callback
});
if (data == null) {
isDataCreator = true;
@ -369,9 +372,11 @@ namespace System.Web {
}
using (dependency) {
cacheInternal.UtcInsert(key, dataAdd, dependency,
DateTime.UtcNow.AddSeconds(5), Cache.NoSlidingExpiration,
CacheItemPriority.Normal, s_callback);
cacheInternal.Insert(key, dataAdd, new CacheInsertOptions() {
Dependencies = dependency,
AbsoluteExpiration = DateTime.UtcNow.AddSeconds(5),
OnRemovedCallback = s_callback
});
}
}
@ -416,7 +421,7 @@ namespace System.Web {
// virtual files.
// An example of a 400 range error is "path not found".
static internal void RemoveBadPathData(CachedPathData pathData) {
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache;
string configPath = pathData._configPath;
string key = CreateKey(configPath);
@ -437,7 +442,7 @@ namespace System.Web {
// status outside the 400 range. We need to mark all data up the path to account for
// virtual files.
static internal void MarkCompleted(CachedPathData pathData) {
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache;
string configPath = pathData._configPath;
do {

View File

@ -1 +1 @@
65f0272002f410cb2fa2a9ac6d2b7c2ef979c154
7ad0d9bd9c7dde1fcdab869ee37fa87177a82006

View File

@ -67,15 +67,13 @@ internal abstract class BuildResultCache {
internal class MemoryBuildResultCache: BuildResultCache {
private CacheInternal _cache;
private CacheItemRemovedCallback _onRemoveCallback;
// The keys are simple assembly names
// The values are ArrayLists containing the simple names of assemblies that depend on it
private Hashtable _dependentAssemblies = new Hashtable();
internal MemoryBuildResultCache(CacheInternal cache) {
_cache = cache;
internal MemoryBuildResultCache() {
// Register an AssemblyLoad event
AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoad);
@ -121,7 +119,7 @@ internal class MemoryBuildResultCache: BuildResultCache {
Debug.Trace("BuildResultCache", "Looking for '" + cacheKey + "' in the memory cache");
string key = GetMemoryCacheKey(cacheKey);
BuildResult result = (BuildResult) _cache.Get(key);
BuildResult result = (BuildResult) HttpRuntime.Cache.InternalCache.Get(key);
// Not found in the cache
if (result == null) {
@ -137,9 +135,9 @@ internal class MemoryBuildResultCache: BuildResultCache {
Debug.Trace("BuildResultCache", "'" + cacheKey + "' was found but is out of date");
// Remove it from the cache
_cache.Remove(key);
HttpRuntime.Cache.InternalCache.Remove(key);
Debug.Assert(_cache.Get(key) == null);
Debug.Assert(HttpRuntime.Cache.InternalCache.Get(key) == null);
return null;
}
@ -183,16 +181,11 @@ internal class MemoryBuildResultCache: BuildResultCache {
// Insert a new cache entry using the assembly path as the key
string assemblyKey = GetAssemblyCacheKey(compiledResult.ResultAssembly);
Assembly a = (Assembly)_cache.Get(assemblyKey);
Assembly a = (Assembly) HttpRuntime.Cache.InternalCache.Get(assemblyKey);
if (a == null) {
Debug.Trace("BuildResultCache", "Adding marker cache entry " + compiledResult.ResultAssembly);
// VSWhidbey 500049 - add as NotRemovable to prevent the assembly from being prematurely deleted
_cache.UtcInsert(assemblyKey, compiledResult.ResultAssembly,
null,
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable,
null);
HttpRuntime.Cache.InternalCache.Insert(assemblyKey, compiledResult.ResultAssembly, null);
}
else {
Debug.Assert(a == compiledResult.ResultAssembly);
@ -237,11 +230,13 @@ internal class MemoryBuildResultCache: BuildResultCache {
onRemoveCallback = _onRemoveCallback;
}
_cache.UtcInsert(key, result, cacheDependency,
result.MemoryCacheExpiration,
result.MemoryCacheSlidingExpiration,
cachePriority,
onRemoveCallback);
HttpRuntime.Cache.InternalCache.Insert(key, result, new CacheInsertOptions() {
Dependencies = cacheDependency,
AbsoluteExpiration = result.MemoryCacheExpiration,
SlidingExpiration = result.MemoryCacheSlidingExpiration,
Priority = cachePriority,
OnRemovedCallback = onRemoveCallback
});
}
// OnCacheItemRemoved can be invoked with user code on the stack, for example if someone
@ -338,7 +333,7 @@ internal class MemoryBuildResultCache: BuildResultCache {
// If we have no cache entry for this assembly, there is nothing to do
string cacheKey = GetAssemblyCacheKeyFromName(assemblyName);
Assembly assembly = (Assembly)_cache[cacheKey];
Assembly assembly = (Assembly)HttpRuntime.Cache.InternalCache.Get(cacheKey);
if (assembly == null)
return;
@ -348,7 +343,7 @@ internal class MemoryBuildResultCache: BuildResultCache {
Debug.Trace("BuildResultCache", "removing cacheKey for assembly " + assemblyPath + " because of dependency change");
// Remove the cache entry in order to kick out all the pages that are in that batch
_cache.Remove(cacheKey);
HttpRuntime.Cache.InternalCache.Remove(cacheKey);
// Now call recursively on all the dependent assemblies (VSWhidbey 577593)
ICollection dependentAssemblies = _dependentAssemblies[assemblyName] as ICollection;
@ -532,7 +527,7 @@ internal abstract class DiskBuildResultCache: BuildResultCache {
// This is required otherwise new components can be compiled
// with obsolete build results whose assembly has been removed.
string assemblyKey = GetAssemblyCacheKey(f.FullName);
HttpRuntime.CacheInternal.Remove(assemblyKey);
HttpRuntime.Cache.InternalCache.Remove(assemblyKey);
// Remove the assembly
RemoveAssembly(f);

View File

@ -188,7 +188,7 @@ internal static class CompilationLock {
// Always take the BuildManager lock *before* taking the mutex, to avoid possible
// deadlock situations (VSWhidbey 530732)
#pragma warning disable 0618
//@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- [....]
//@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- Microsoft
Monitor.Enter(BuildManager.TheBuildManager);
#pragma warning restore 0618
_mutex.WaitOne();

View File

@ -271,9 +271,9 @@ namespace System.Web.Compilation {
"." + classKey;
// If we have it cached, return it
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
string cacheKey = CacheInternal.PrefixResourceProvider + fullClassName;
IResourceProvider resourceProvider = cacheInternal[cacheKey] as IResourceProvider;
IResourceProvider resourceProvider = cacheInternal.Get(cacheKey) as IResourceProvider;
if (resourceProvider != null) {
return resourceProvider;
}
@ -282,7 +282,7 @@ namespace System.Web.Compilation {
resourceProvider = s_resourceProviderFactory.CreateGlobalResourceProvider(classKey);
// Cache it
cacheInternal.UtcInsert(cacheKey, resourceProvider);
cacheInternal.Insert(cacheKey, resourceProvider, null);
return resourceProvider;
}
@ -296,9 +296,9 @@ namespace System.Web.Compilation {
internal static IResourceProvider GetLocalResourceProvider(VirtualPath virtualPath) {
// If we have it cached, return it (it may be null if there are no local resources)
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
string cacheKey = CacheInternal.PrefixResourceProvider + virtualPath.VirtualPathString;
IResourceProvider resourceProvider = cacheInternal[cacheKey] as IResourceProvider;
IResourceProvider resourceProvider = cacheInternal.Get(cacheKey) as IResourceProvider;
if (resourceProvider != null) {
return resourceProvider;
}
@ -307,7 +307,7 @@ namespace System.Web.Compilation {
resourceProvider = s_resourceProviderFactory.CreateLocalResourceProvider(virtualPath.VirtualPathString);
// Cache it
cacheInternal.UtcInsert(cacheKey, resourceProvider);
cacheInternal.Insert(cacheKey, resourceProvider, null);
return resourceProvider;
}

View File

@ -19,14 +19,20 @@ namespace System.Web.Configuration {
/*
<!--
cache Attributes:
defaultProvider="name" - a name matching a provider in the provider list to use for Object and Internal cache.
cacheAPIEnabled="[true|false]" - Enable or disable the user Cache API
disableMemoryCollection="[true|false]" - Enable or disable the cache memory collection
disableExpiration="[true|false]" - Enable or disable the expiration of items from the cache
privateBytesLimit="number" - Represents maximum private bytes (in bytes) allowed. If it's zero, Cache will use an auto-generated limit. Cache will collect memory when the private bytes is near the limit. This works on top of other memory indexes monitored by Cache.
percentagePhysicalMemoryUsedLimit="number" - Represents percentage of physical memory process allowed. Cache will collect memory when the private bytes is near the limit. This works on top of other memory indexes monitored by Cache.
privateBytesPollTime="timespan" - How often we poll the process memory by calling NtQuerySystemInformation. Default is 2 min.
-->
<cache cacheAPIEnabled="true" />
<cache cacheAPIEnabled="true" defaultProvider="name" >
<providers>
<add name="string" type="string" ... />
</providers>
</cache>
*/
public sealed class CacheSection : ConfigurationSection {
@ -44,6 +50,9 @@ namespace System.Web.Configuration {
private static readonly ConfigurationProperty _propPercentagePhysicalMemoryUsedLimit;
private static readonly ConfigurationProperty _propPrivateBytesPollTime;
private static readonly ConfigurationProperty _propProviders;
private static readonly ConfigurationProperty _propDefaultProvider;
static CacheSection() {
// Property initialization
@ -51,6 +60,14 @@ namespace System.Web.Configuration {
_propCacheAPIEnabled = new ConfigurationProperty("cacheAPIEnabled", typeof(bool), true, ConfigurationPropertyOptions.None);
_propDisableDependencies = new ConfigurationProperty("disableDependencies", typeof(bool), false, ConfigurationPropertyOptions.None);
#endif
_propProviders = new ConfigurationProperty("providers", typeof(ProviderSettingsCollection), null, ConfigurationPropertyOptions.None);
_propDefaultProvider =
new ConfigurationProperty("defaultProvider",
typeof(string),
null,
null,
StdValidatorsAndConverters.NonEmptyStringValidator,
ConfigurationPropertyOptions.None);
_propDisableMemoryCollection =
new ConfigurationProperty("disableMemoryCollection",
@ -91,6 +108,8 @@ namespace System.Web.Configuration {
_properties.Add(_propDisableDependencies);
#endif
_properties.Add(_propProviders);
_properties.Add(_propDefaultProvider);
_properties.Add(_propDisableMemoryCollection);
_properties.Add(_propDisableExpiration);
_properties.Add(_propPrivateBytesLimit);
@ -101,6 +120,24 @@ namespace System.Web.Configuration {
public CacheSection() {
}
[ConfigurationProperty("providers")]
public ProviderSettingsCollection Providers {
get {
return (ProviderSettingsCollection)base[_propProviders];
}
}
[ConfigurationProperty("defaultProvider", DefaultValue = null)]
[StringValidator(MinLength = 1)]
public string DefaultProvider {
get {
return (string)base[_propDefaultProvider];
}
set {
base[_propDefaultProvider] = value;
}
}
#if NOT_UNTIL_LATER
[ConfigurationProperty("cacheAPIEnabled", DefaultValue = true)]
public bool CacheAPIEnabled

View File

@ -15,6 +15,7 @@ namespace System.Web.Configuration {
using System.Web.Compilation;
using System.Security;
using System.Security.Permissions;
using System.Web;
/*
* An object to cache a factory
@ -37,6 +38,7 @@ namespace System.Web.Configuration {
else {
throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
}
TelemetryLogger.LogHttpHandler(instance.GetType());
}
internal HandlerFactoryCache(HttpHandlerAction mapping) {
@ -54,6 +56,7 @@ namespace System.Web.Configuration {
else {
throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
}
TelemetryLogger.LogHttpHandler(instance.GetType());
}
internal IHttpHandlerFactory Factory {

View File

@ -211,7 +211,7 @@ namespace System.Web.Configuration {
private void CacheBrowserCapResult(ref HttpCapabilitiesBase result) {
// Use the previously cached browserCap object if an identical
// browserCap is found.
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
if (result.Capabilities == null) {
return;
@ -241,7 +241,7 @@ namespace System.Web.Configuration {
}
else {
// cache it and respect cachetime
cacheInternal.UtcInsert(hashKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
cacheInternal.Insert(hashKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
}
}
@ -255,7 +255,7 @@ namespace System.Web.Configuration {
internal HttpCapabilitiesBase Evaluate(HttpRequest request) {
HttpCapabilitiesBase result;
CacheInternal cacheInternal = System.Web.HttpRuntime.CacheInternal;
CacheStoreProvider cacheInternal = System.Web.HttpRuntime.Cache.InternalCache;
//
// 1) grab UA and do optimistic cache lookup (if UA is in dependency list)
@ -298,7 +298,7 @@ namespace System.Web.Configuration {
CacheBrowserCapResult(ref result);
// Cache the result using the optimisicCacheKey
cacheInternal.UtcInsert(optimisticCacheKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
cacheInternal.Insert(optimisticCacheKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
return result;
}
@ -363,9 +363,9 @@ namespace System.Web.Configuration {
CacheBrowserCapResult(ref result);
// cache it and respect _cachetime
cacheInternal.UtcInsert(fullCacheKey, result, null, Cache.NoAbsoluteExpiration, _cachetime);
cacheInternal.Insert(fullCacheKey, result, new CacheInsertOptions() { SlidingExpiration = _cachetime });
if(optimisticCacheKey != null) {
cacheInternal.UtcInsert(optimisticCacheKey, _disableOptimisticCachingSingleton, null, Cache.NoAbsoluteExpiration, _cachetime);
cacheInternal.Insert(optimisticCacheKey, _disableOptimisticCachingSingleton, new CacheInsertOptions() { SlidingExpiration = _cachetime });
}
return result;

View File

@ -226,7 +226,7 @@ namespace System.Web.Configuration {
else {
// Check if it's in the cache
String cacheKey = CacheInternal.PrefixMapPath + siteID + path.VirtualPathString;
cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Get(cacheKey);
cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Get(cacheKey);
// If not in cache, add it to the cache
if (cacheInfo == null) {
@ -234,8 +234,7 @@ namespace System.Web.Configuration {
// Add to the cache.
// No need to have a lock here. UtcAdd will add the entry if it doesn't exist.
// If it does exist, the existing value will be returned (Dev10 Bug 755034).
object existingEntry = HttpRuntime.CacheInternal.UtcAdd(
cacheKey, cacheInfo, null, Cache.NoAbsoluteExpiration, slidingExpiration, CacheItemPriority.Default, null);
object existingEntry = HttpRuntime.Cache.InternalCache.Add(cacheKey, cacheInfo, new CacheInsertOptions() { SlidingExpiration = slidingExpiration });
if (existingEntry != null) {
cacheInfo = existingEntry as MapPathCacheInfo;
}

View File

@ -224,7 +224,7 @@ namespace System.Web.Configuration {
else {
// Check if it's in the cache
String cacheKey = CacheInternal.PrefixMapPath + siteID + path.VirtualPathString;
cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Get(cacheKey);
cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Get(cacheKey);
// If not in cache, add it to the cache
if (cacheInfo == null) {
@ -232,8 +232,7 @@ namespace System.Web.Configuration {
// Add to the cache.
// No need to have a lock here. UtcAdd will add the entry if it doesn't exist.
// If it does exist, the existing value will be returned (Dev10 Bug 755034).
object existingEntry = HttpRuntime.CacheInternal.UtcAdd(
cacheKey, cacheInfo, null, Cache.NoAbsoluteExpiration, slidingExpiration, CacheItemPriority.Default, null);
object existingEntry = HttpRuntime.Cache.InternalCache.Add(cacheKey, cacheInfo, new CacheInsertOptions() { SlidingExpiration = slidingExpiration });
if (existingEntry != null) {
cacheInfo = existingEntry as MapPathCacheInfo;
}

View File

@ -46,6 +46,35 @@ namespace System.Web.Configuration
return provider;
}
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)]
internal static ProviderBase InstantiateProvider(NameValueCollection providerSettings, Type providerType) {
ProviderBase provider = null;
try {
string pnName = GetAndRemoveStringValue(providerSettings, "name");
string pnType = GetAndRemoveStringValue(providerSettings, "type");
if (string.IsNullOrEmpty(pnType))
throw new ArgumentException(SR.GetString(SR.Provider_no_type_name));
Type t = ConfigUtil.GetType(pnType, "type", null, null, true, true);
if (!providerType.IsAssignableFrom(t))
throw new ArgumentException(SR.GetString(SR.Provider_must_implement_type, providerType.ToString()));
provider = (ProviderBase)HttpRuntime.CreatePublicInstance(t);
// Because providers modify the parameters collection (i.e. delete stuff), pass in a clone of the collection
NameValueCollection cloneParams = new NameValueCollection(providerSettings.Count, StringComparer.Ordinal);
foreach (string key in providerSettings)
cloneParams[key] = providerSettings[key];
provider.Initialize(pnName, cloneParams);
}
catch (Exception e) {
if (e is ConfigurationException)
throw;
throw new ConfigurationErrorsException(e.Message, e);
}
return provider;
}
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)]
public static void InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
{
@ -53,5 +82,13 @@ namespace System.Web.Configuration
providers.Add(InstantiateProvider(ps, providerType));
}
}
private static string GetAndRemoveStringValue(NameValueCollection collection, string key) {
string strValue = collection[key] as string;
if (!string.IsNullOrEmpty(strValue))
strValue = strValue.Trim();
collection.Remove(key);
return strValue;
}
}
}

View File

@ -392,7 +392,7 @@ namespace System.Web.Configuration {
return (string)base[_propLockAttributes];
}
set {
// base.LockedAttributes.SetFromList(value); // keep the internal list in [....]
// base.LockedAttributes.SetFromList(value); // keep the internal list in sync
base[_propLockAttributes] = value;
}
}

View File

@ -1 +1 @@
e4b03d4752a7028638c7b89fed7946289eda792b
f60acb0bc25b84f7837890c0473e4a133cb35e8b

View File

@ -9,7 +9,9 @@ namespace System.Web.Hosting {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Provider;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
@ -88,9 +90,6 @@ namespace System.Web.Hosting {
// single instance of app manager
private static ApplicationManager _theAppManager;
// single instance of cache manager
private static CacheManager _cm;
// store fatal exception to assist debugging
private static Exception _fatalException = null;
@ -105,52 +104,6 @@ namespace System.Web.Hosting {
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
}
private void InitCacheManager(long privateBytesLimit) {
if (_cm == null) {
lock (_applicationManagerStaticLock) {
if (_cm == null && !_shutdownInProgress) {
_cm = new CacheManager(this, privateBytesLimit);
}
}
}
}
private void DisposeCacheManager() {
if (_cm != null) {
lock (_applicationManagerStaticLock) {
if (_cm != null) {
_cm.Dispose();
_cm = null;
}
}
}
}
// Each cache must update the total with the difference between it's current size and it's previous size.
// To reduce cross-domain costs, this also returns the updated total size.
internal long GetUpdatedTotalCacheSize(long sizeUpdate) {
CacheManager cm = _cm;
return (cm != null) ? cm.GetUpdatedTotalCacheSize(sizeUpdate) : 0;
}
internal long TrimCaches(int percent) {
long trimmedOrExpired = 0;
Dictionary<string, LockableAppDomainContext> apps = CloneAppDomainsCollection();
foreach (LockableAppDomainContext ac in apps.Values) {
lock (ac) {
HostingEnvironment env = ac.HostEnv;
if (_shutdownInProgress) {
break;
}
if (env == null) {
continue;
}
trimmedOrExpired += env.TrimCache(percent);
}
}
return trimmedOrExpired;
}
internal bool ShutdownInProgress {
get {
return _shutdownInProgress;
@ -468,6 +421,10 @@ namespace System.Web.Hosting {
return GetAppDomain(appID);
}
internal AppDomain GetDefaultAppDomain() {
return AppDomain.CurrentDomain;
}
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "This isn't a dangerous method.")]
private string CreateSimpleAppID(IApplicationHost appHost) {
if (appHost == null) {
@ -565,8 +522,6 @@ namespace System.Web.Hosting {
_shutdownInProgress = true;
Dictionary <string, LockableAppDomainContext> oldTable = null;
DisposeCacheManager();
lock (this) {
oldTable = _appDomains;
// don't keep references to hosting environments anymore
@ -769,13 +724,8 @@ namespace System.Web.Hosting {
// communication with hosting environments
//
internal void HostingEnvironmentActivated(long privateBytesLimit) {
internal void HostingEnvironmentActivated() {
int count = Interlocked.Increment(ref _activeHostingEnvCount);
// initialize CacheManager once, without blocking
if (count == 1) {
InitCacheManager(privateBytesLimit);
}
}
internal void HostingEnvironmentShutdownComplete(String appId, IApplicationHost appHost) {
@ -1021,7 +971,7 @@ namespace System.Web.Hosting {
//Hosted by IIS, we already have an IISMap.
if (appHost is ISAPIApplicationHost) {
string cacheKey = System.Web.Caching.CacheInternal.PrefixMapPath + siteID + virtualPath.VirtualPathString;
MapPathCacheInfo cacheInfo = (MapPathCacheInfo)HttpRuntime.CacheInternal.Remove(cacheKey);
MapPathCacheInfo cacheInfo = (MapPathCacheInfo)HttpRuntime.Cache.InternalCache.Remove(cacheKey);
appConfig = WebConfigurationManager.OpenWebConfiguration(appSegment, siteID);
}
// For non-IIS hosting scenarios, we need to get config map from application host in a generic way.
@ -1117,6 +1067,25 @@ namespace System.Web.Hosting {
}
}
// Allow apps to use their own CacheStoreProvider implementations
CacheSection cacheConfig = (CacheSection)appConfig.GetSection("system.web/caching/cache");
if (cacheConfig != null && cacheConfig.DefaultProvider != null && !String.IsNullOrWhiteSpace(cacheConfig.DefaultProvider)) {
ProviderSettingsCollection cacheProviders = cacheConfig.Providers;
if (cacheProviders == null || cacheProviders.Count < 1) {
throw new ProviderException(SR.GetString(SR.Def_provider_not_found));
}
ProviderSettings cacheProviderSettings = cacheProviders[cacheConfig.DefaultProvider];
if (cacheProviderSettings == null) {
throw new ProviderException(SR.GetString(SR.Def_provider_not_found));
} else {
NameValueCollection settings = cacheProviderSettings.Parameters;
settings["name"] = cacheProviderSettings.Name;
settings["type"] = cacheProviderSettings.Type;
appDomainAdditionalData[".defaultObjectCacheProvider"] = settings;
}
}
// If we were launched from a development environment, we might want to enable the application to do things
// it otherwise wouldn't normally allow, such as enabling an administrative control panel. For security reasons,
// we only do this check if <deployment retail="false" /> [the default value] is specified, since the

Some files were not shown because too many files have changed in this diff Show More