From 93941b00e3ba59db5bb8f5dd412f6051c2cb823e Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 30 Jan 2014 16:57:10 -0800 Subject: [PATCH] Disposing sessions correctly --- src/Orchard/Data/SessionLocator.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Orchard/Data/SessionLocator.cs b/src/Orchard/Data/SessionLocator.cs index edbb8212e..6a75098b1 100644 --- a/src/Orchard/Data/SessionLocator.cs +++ b/src/Orchard/Data/SessionLocator.cs @@ -101,6 +101,12 @@ namespace Orchard.Data { _cancelled = false; } } + + if (_session != null) { + _session.Dispose(); + _session = null; + } + } private void EnsureSession() { @@ -116,7 +122,6 @@ namespace Orchard.Data { class OrchardSessionInterceptor : IInterceptor { private readonly ISessionInterceptor[] _interceptors; private readonly ILogger _logger; - private ISession _session; public OrchardSessionInterceptor(ISessionInterceptor[] interceptors, ILogger logger) { _interceptors = interceptors; @@ -238,8 +243,6 @@ namespace Orchard.Data { } void IInterceptor.SetSession(ISession session) { - _session = session; - if (_interceptors.Length == 0) return; _interceptors.Invoke(i => i.SetSession(session), _logger); }