mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Made output cache lock management more robust.
This commit is contained in:
@@ -165,11 +165,14 @@ namespace Orchard.OutputCache.Filters {
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {
|
||||
if (!_isCachingRequest)
|
||||
return;
|
||||
|
||||
var captureHandlerIsAttached = false;
|
||||
|
||||
try {
|
||||
|
||||
if (!_isCachingRequest)
|
||||
return;
|
||||
|
||||
Logger.Debug("Item '{0}' was rendered.", _cacheKey);
|
||||
|
||||
// Obtain individual route configuration, if any.
|
||||
@@ -232,14 +235,15 @@ namespace Orchard.OutputCache.Filters {
|
||||
ReleaseCacheKeyLock();
|
||||
}
|
||||
};
|
||||
|
||||
captureHandlerIsAttached = true;
|
||||
}
|
||||
catch {
|
||||
// If an exception is caught, it means we were never able to attach the Captured
|
||||
// event handler to the CaptureStream instance, because attaching that handler is
|
||||
// the very last statement in the try block. Hence we can't assume that event
|
||||
// handler to release the cache key lock, and we should do it here.
|
||||
finally {
|
||||
// If the response filter stream capture handler was attached then we'll trust
|
||||
// it to release the cache key lock at some point in the future when the stream
|
||||
// is flushed; otherwise we'll make sure we'll release it here.
|
||||
if (!captureHandlerIsAttached)
|
||||
ReleaseCacheKeyLock();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user