From: <aye...@us...> - 2009-11-20 15:18:40
|
Revision: 4840 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4840&view=rev Author: ayenderahien Date: 2009-11-20 15:18:26 +0000 (Fri, 20 Nov 2009) Log Message: ----------- Fixing perf problem with SessionIdLoggingContext (NH-2007) Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-11-19 16:04:43 UTC (rev 4839) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-11-20 15:18:26 UTC (rev 4840) @@ -9,8 +9,6 @@ { [ThreadStatic] private static Guid? CurrentSessionId; - private const string CurrentSessionIdKey = "NHibernate.Impl.SessionIdLoggingContext.CurrentSessionId"; - private readonly Guid? oldSessonId; public SessionIdLoggingContext(Guid id) @@ -20,24 +18,21 @@ } /// <summary> - /// Error handling in this case will only kick in if we cannot set values on the TLS - /// this is usally the case if we are called from the finalizer, since this is something - /// that we do only for logging, we ignore the error. + /// We always set the result to use a thread static variable, on the face of it, + /// it looks like it is not a valid choice, since ASP.Net and WCF may decide to switch + /// threads on us. But, since SessionIdLoggingContext is only used inside NH calls, and since + /// NH calls are never async, this isn't an issue for us. + /// In addition to that, attempting to match to the current context has proven to be performance hit. /// </summary> public static Guid? SessionId { get { - if (HttpContext.Current != null) - return (Guid?)HttpContext.Current.Items[CurrentSessionIdKey]; return CurrentSessionId; } set { - if (HttpContext.Current != null) - HttpContext.Current.Items[CurrentSessionIdKey] = value; - else - CurrentSessionId = value; + CurrentSessionId = value; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |