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