Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Remove empty Threadpool .cctors
Browse files Browse the repository at this point in the history
Initalize threadpool statics in SecuritySafeCritical path
  • Loading branch information
benaadams committed Feb 15, 2016
1 parent 2ec6a40 commit 8f15732
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions src/mscorlib/src/System/Threading/ThreadPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ internal static class ThreadPoolGlobals
public static bool enableWorkerTracking;

[SecurityCritical]
public static ThreadPoolWorkQueue workQueue = new ThreadPoolWorkQueue();
public static ThreadPoolWorkQueue workQueue;

[System.Security.SecuritySafeCritical] // static constructors should be safe to call
static ThreadPoolGlobals()
[SecurityCritical]
internal static void Initialize()
{
workQueue = new ThreadPoolWorkQueue();
}
}

Expand Down Expand Up @@ -1168,9 +1169,6 @@ internal interface IThreadPoolWorkItem

internal sealed class QueueUserWorkItemCallback : IThreadPoolWorkItem
{
[System.Security.SecuritySafeCritical]
static QueueUserWorkItemCallback() {}

private WaitCallback callback;
private ExecutionContext context;
private Object state;
Expand Down Expand Up @@ -1232,7 +1230,13 @@ void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae)
}

[System.Security.SecurityCritical]
static internal ContextCallback ccb = new ContextCallback(WaitCallback_Context);
static internal ContextCallback ccb;

[System.Security.SecurityCritical]
static internal void Initialize()
{
ccb = new ContextCallback(WaitCallback_Context);
}

[System.Security.SecurityCritical]
static private void WaitCallback_Context(Object state)
Expand Down Expand Up @@ -1298,7 +1302,13 @@ void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae)
}

[System.Security.SecurityCritical]
static internal ContextCallback ccb = new ContextCallback(WaitCallback_Context);
static internal ContextCallback ccb;

[System.Security.SecurityCritical]
static internal void Initialize()
{
ccb = new ContextCallback(WaitCallback_Context);
}

[System.Security.SecurityCritical]
static private void WaitCallback_Context(Object state)
Expand All @@ -1313,16 +1323,20 @@ static private void WaitCallback_Context(Object state)

internal class _ThreadPoolWaitOrTimerCallback
{
[System.Security.SecuritySafeCritical]
static _ThreadPoolWaitOrTimerCallback() {}

WaitOrTimerCallback _waitOrTimerCallback;
ExecutionContext _executionContext;
Object _state;
[System.Security.SecurityCritical]
static private ContextCallback _ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
static private ContextCallback _ccbt;
[System.Security.SecurityCritical]
static private ContextCallback _ccbf = new ContextCallback(WaitOrTimerCallback_Context_f);
static private ContextCallback _ccbf;

[System.Security.SecurityCritical]
static internal void Initialize()
{
_ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
_ccbf = new ContextCallback(WaitOrTimerCallback_Context_f);
}

[System.Security.SecurityCritical] // auto-generated
internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, Object state, bool compressStack, ref StackCrawlMark stackMark)
Expand Down Expand Up @@ -1845,6 +1859,12 @@ private static void EnsureVMInitialized()
if (!ThreadPoolGlobals.vmTpInitialized)
{
ThreadPool.InitializeVMTp(ref ThreadPoolGlobals.enableWorkerTracking);

ThreadPoolGlobals.Initialize();
QueueUserWorkItemCallback.Initialize();
QueueUserWorkItemCallbackDefaultContext.Initialize();
_ThreadPoolWaitOrTimerCallback.Initialize();

ThreadPoolGlobals.vmTpInitialized = true;
}
}
Expand Down

0 comments on commit 8f15732

Please sign in to comment.