From b667bff8bb7375b2e358871cddb83b42ba01163f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 30 Dec 2020 11:53:46 +0000 Subject: [PATCH] smartthreadpool: httpcontext will be gone (we dont use it) --- .../SmartThreadPool/CallerThreadContext.cs | 42 +------------------ ThirdParty/SmartThreadPool/SmartThreadPool.cs | 6 --- ThirdParty/SmartThreadPool/WIGStartInfo.cs | 17 -------- ThirdParty/SmartThreadPool/WorkItem.cs | 6 +-- ThirdParty/SmartThreadPool/WorkItemFactory.cs | 6 --- ThirdParty/SmartThreadPool/WorkItemInfo.cs | 7 ---- 6 files changed, 5 insertions(+), 79 deletions(-) diff --git a/ThirdParty/SmartThreadPool/CallerThreadContext.cs b/ThirdParty/SmartThreadPool/CallerThreadContext.cs index 82653985a7..cf1c8789e5 100644 --- a/ThirdParty/SmartThreadPool/CallerThreadContext.cs +++ b/ThirdParty/SmartThreadPool/CallerThreadContext.cs @@ -28,25 +28,10 @@ namespace Amib.Threading.Internal private static readonly MethodInfo setLogicalCallContextMethodInfo = typeof(Thread).GetMethod("SetLogicalCallContext", BindingFlags.Instance | BindingFlags.NonPublic); - private static string HttpContextSlotName = GetHttpContextSlotName(); - - private static string GetHttpContextSlotName() - { - FieldInfo fi = typeof(HttpContext).GetField("CallContextSlotName", BindingFlags.Static | BindingFlags.NonPublic); - - if (fi != null) - { - return (string)fi.GetValue(null); - } - - return "HttpContext"; - } - #endregion #region Private fields - private HttpContext _httpContext; private LogicalCallContext _callContext; #endregion @@ -66,23 +51,13 @@ namespace Amib.Threading.Internal } } - public bool CapturedHttpContext - { - get - { - return (null != _httpContext); - } - } - /// /// Captures the current thread context /// /// - public static CallerThreadContext Capture( - bool captureCallContext, - bool captureHttpContext) + public static CallerThreadContext Capture(bool captureCallContext) { - Debug.Assert(captureCallContext || captureHttpContext); + Debug.Assert(captureCallContext); CallerThreadContext callerThreadContext = new CallerThreadContext(); @@ -97,12 +72,6 @@ namespace Amib.Threading.Internal } } - // Capture httpContext - if (captureHttpContext && (null != HttpContext.Current)) - { - callerThreadContext._httpContext = HttpContext.Current; - } - return callerThreadContext; } @@ -123,13 +92,6 @@ namespace Amib.Threading.Internal { setLogicalCallContextMethodInfo.Invoke(Thread.CurrentThread, new object[] { callerThreadContext._callContext }); } - - // Restore HttpContext - if (callerThreadContext._httpContext != null) - { - HttpContext.Current = callerThreadContext._httpContext; - //CallContext.SetData(HttpContextSlotName, callerThreadContext._httpContext); - } } } diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.cs b/ThirdParty/SmartThreadPool/SmartThreadPool.cs index 26744c493f..5acef1cad8 100644 --- a/ThirdParty/SmartThreadPool/SmartThreadPool.cs +++ b/ThirdParty/SmartThreadPool/SmartThreadPool.cs @@ -47,7 +47,6 @@ // - Added option to start the STP and the WIG as suspended // - Exception behavior changed, the real exception is returned by an // inner exception -// - Added option to keep the Http context of the caller thread. (Thanks to Steven T.) // - Added performance counters // - Added priority to the threads in the pool // @@ -136,11 +135,6 @@ namespace Amib.Threading /// public const bool DefaultUseCallerCallContext = false; - /// - /// Indicate to copy the HTTP context of the caller and then use it in the call. (false) - /// - public const bool DefaultUseCallerHttpContext = false; - /// /// Indicate to dispose of the state objects if they support the IDispose interface. (false) /// diff --git a/ThirdParty/SmartThreadPool/WIGStartInfo.cs b/ThirdParty/SmartThreadPool/WIGStartInfo.cs index 4ea92b9c56..c812dbe6e3 100644 --- a/ThirdParty/SmartThreadPool/WIGStartInfo.cs +++ b/ThirdParty/SmartThreadPool/WIGStartInfo.cs @@ -8,7 +8,6 @@ namespace Amib.Threading public class WIGStartInfo { private bool _useCallerCallContext; - private bool _useCallerHttpContext; private bool _disposeOfStateObjects; private CallToPostExecute _callToPostExecute; private PostExecuteWorkItemCallback _postExecuteWorkItemCallback; @@ -26,14 +25,12 @@ namespace Amib.Threading _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute; _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; - _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; } public WIGStartInfo(WIGStartInfo wigStartInfo) { _useCallerCallContext = wigStartInfo.UseCallerCallContext; - _useCallerHttpContext = wigStartInfo.UseCallerHttpContext; _disposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; _callToPostExecute = wigStartInfo.CallToPostExecute; _postExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; @@ -64,20 +61,6 @@ namespace Amib.Threading } - /// - /// Get/Set if to use the caller's HTTP context - /// - public virtual bool UseCallerHttpContext - { - get { return _useCallerHttpContext; } - set - { - ThrowIfReadOnly(); - _useCallerHttpContext = value; - } - } - - /// /// Get/Set if to dispose of the state object of a work item /// diff --git a/ThirdParty/SmartThreadPool/WorkItem.cs b/ThirdParty/SmartThreadPool/WorkItem.cs index 7dd32de8bb..dd2d24f70d 100644 --- a/ThirdParty/SmartThreadPool/WorkItem.cs +++ b/ThirdParty/SmartThreadPool/WorkItem.cs @@ -208,9 +208,9 @@ namespace Amib.Threading.Internal _workItemsGroup = workItemsGroup; _workItemInfo = workItemInfo; - if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext) + if (_workItemInfo.UseCallerCallContext) { - _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext); + _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext); } _callback = callback; @@ -359,7 +359,7 @@ namespace Amib.Threading.Internal CallerThreadContext ctc = null; if (null != _callerContext) { - ctc = CallerThreadContext.Capture(_callerContext.CapturedCallContext, _callerContext.CapturedHttpContext); + ctc = CallerThreadContext.Capture(_callerContext.CapturedCallContext); CallerThreadContext.Apply(_callerContext); } diff --git a/ThirdParty/SmartThreadPool/WorkItemFactory.cs b/ThirdParty/SmartThreadPool/WorkItemFactory.cs index 6a2e95b78b..6983a2a2e4 100644 --- a/ThirdParty/SmartThreadPool/WorkItemFactory.cs +++ b/ThirdParty/SmartThreadPool/WorkItemFactory.cs @@ -80,7 +80,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; @@ -116,7 +115,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; @@ -186,7 +184,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; @@ -228,7 +225,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; @@ -270,7 +266,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; workItemInfo.CallToPostExecute = callToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; @@ -315,7 +310,6 @@ namespace Amib.Threading.Internal WorkItemInfo workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; - workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = postExecuteWorkItemCallback; workItemInfo.CallToPostExecute = callToPostExecute; workItemInfo.WorkItemPriority = workItemPriority; diff --git a/ThirdParty/SmartThreadPool/WorkItemInfo.cs b/ThirdParty/SmartThreadPool/WorkItemInfo.cs index 5be82a2f04..4d82e2a804 100644 --- a/ThirdParty/SmartThreadPool/WorkItemInfo.cs +++ b/ThirdParty/SmartThreadPool/WorkItemInfo.cs @@ -10,7 +10,6 @@ namespace Amib.Threading public WorkItemInfo() { UseCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; - UseCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; DisposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; CallToPostExecute = SmartThreadPool.DefaultCallToPostExecute; PostExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; @@ -20,7 +19,6 @@ namespace Amib.Threading public WorkItemInfo(WorkItemInfo workItemInfo) { UseCallerCallContext = workItemInfo.UseCallerCallContext; - UseCallerHttpContext = workItemInfo.UseCallerHttpContext; DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; CallToPostExecute = workItemInfo.CallToPostExecute; PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; @@ -33,11 +31,6 @@ namespace Amib.Threading /// public bool UseCallerCallContext { get; set; } - /// - /// Get/Set if to use the caller's HTTP context - /// - public bool UseCallerHttpContext { get; set; } - /// /// Get/Set if to dispose of the state object of a work item ///