EEPolicy::HandleExitProcess(sca);
}
-static bool WaitForEndOfShutdown_OneIteration()
-{
- CONTRACTL{
- NOTHROW;
- GC_NOTRIGGER;
- MODE_PREEMPTIVE;
- } CONTRACTL_END;
-
- // We are shutting down. GC triggers does not have any effect now.
- CONTRACT_VIOLATION(GCViolation);
-
- // If someone calls EEShutDown while holding OS loader lock, the thread we created for shutdown
- // won't start running. This is a deadlock we can not fix. Instead, we timeout and continue the
- // current thread.
- DWORD timeout = GetEEPolicy()->GetTimeout(OPR_ProcessExit);
- timeout *= 2;
- ULONGLONG endTime = CLRGetTickCount64() + timeout;
- bool done = false;
-
- EX_TRY
- {
- ULONGLONG curTime = CLRGetTickCount64();
- if (curTime > endTime)
- {
- done = true;
- }
- else
- {
-#ifdef PROFILING_SUPPORTED
- if (CORProfilerPresent())
- {
- // A profiler is loaded, so just wait without timeout. This allows
- // profilers to complete potentially lengthy post processing, without the
- // CLR killing them off first. The Office team's server memory profiler,
- // for example, does a lot of post-processing that can exceed the 80
- // second imit we normally impose here. The risk of waiting without
- // timeout is that, if there really is a deadlock, shutdown will hang.
- // Since that will only happen if a profiler is loaded, that is a
- // reasonable compromise
- timeout = INFINITE;
- }
- else
-#endif //PROFILING_SUPPORTED
- {
- timeout = static_cast<DWORD>(endTime - curTime);
- }
- DWORD status = g_pEEShutDownEvent->Wait(timeout,TRUE);
- if (status == WAIT_OBJECT_0 || status == WAIT_TIMEOUT)
- {
- done = true;
- }
- else
- {
- done = false;
- }
- }
- }
- EX_CATCH
- {
- }
- EX_END_CATCH(SwallowAllExceptions);
- return done;
-}
-
void WaitForEndOfShutdown()
{
CONTRACTL{
pThread->SetThreadStateNC(Thread::TSNC_BlockedForShutdown);
}
- while (!WaitForEndOfShutdown_OneIteration());
+ for (;;) g_pEEShutDownEvent->Wait(INFINITE, TRUE);
}
// ---------------------------------------------------------------------------
m_ActionOnFailure[FAIL_NonCriticalResource] = eThrowException;
m_ActionOnFailure[FAIL_OrphanedLock] = eNoAction;
m_ActionOnFailure[FAIL_FatalRuntime] = eRudeExitProcess;
- // For CoreCLR, initialize the default action for AV processing to all
- // all kind of code to catch AV exception. If the host wants, they can
- // specify a different action for this.
m_ActionOnFailure[FAIL_StackOverflow] = eRudeExitProcess;
}
EEPolicy ();
- DWORD GetTimeout(EClrOperation operation)
- {
- LIMITED_METHOD_CONTRACT;
- _ASSERTE(static_cast<UINT>(operation) < MaxClrOperation);
- return INFINITE; // No hardcoded timeouts
- }
-
EPolicyAction GetActionOnTimeout(EClrOperation operation, Thread *pThread)
{
WRAPPER_NO_CONTRACT;
_ASSERTE (!"unknown policy for thread abort");
}
- DWORD timeoutFromPolicy;
- if (abortType != EEPolicy::TA_Rude)
- {
- timeoutFromPolicy = GetEEPolicy()->GetTimeout(OPR_ThreadAbort);
- }
- else
- {
- timeoutFromPolicy = GetEEPolicy()->GetTimeout(OPR_ThreadRudeAbortInCriticalRegion);
- }
- if (timeout > timeoutFromPolicy)
- {
- timeout = timeoutFromPolicy;
- }
+ timeout = INFINITE;
}
AbortControlHolder AbortController(this);
if (now_time >= abortEndTime)
{
EPolicyAction action1 = eNoAction;
- DWORD timeout1 = INFINITE;
if (fEscalation)
{
if (!IsRudeAbort())
{
action1 = GetEEPolicy()->GetActionOnTimeout(OPR_ThreadAbort, this);
- timeout1 = GetEEPolicy()->GetTimeout(OPR_ThreadAbort);
}
else
{
action1 = GetEEPolicy()->GetActionOnTimeout(OPR_ThreadRudeAbortInCriticalRegion, this);
- timeout1 = GetEEPolicy()->GetTimeout(OPR_ThreadRudeAbortInCriticalRegion);
}
}
if (action1 == eNoAction)
// Debugger can call this function to about func-eval with a timeout
return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
}
- if (timeout1 != INFINITE)
- {
- break;
- }
}
}
void Thread::SetRudeAbortEndTimeFromEEPolicy()
{
LIMITED_METHOD_CONTRACT;
-
- DWORD timeout = GetEEPolicy()->GetTimeout(OPR_ThreadRudeAbortInCriticalRegion);
-
- ULONGLONG newEndTime;
- if (timeout == INFINITE)
- {
- newEndTime = MAXULONGLONG;
- }
- else
- {
- newEndTime = CLRGetTickCount64() + timeout;
- }
-
- SetAbortEndTime(newEndTime, TRUE);
+ SetAbortEndTime(MAXULONGLONG, TRUE);
}
ULONGLONG Thread::s_NextSelfAbortEndTime = MAXULONGLONG;
return;
}
- if (requester == TAR_Thread)
- {
- DWORD timeoutFromPolicy;
- if (abortType != EEPolicy::TA_Rude)
- {
- timeoutFromPolicy = GetEEPolicy()->GetTimeout(OPR_ThreadAbort);
- }
- else
- {
- timeoutFromPolicy = GetEEPolicy()->GetTimeout(OPR_ThreadRudeAbortInCriticalRegion);
- }
- if (timeoutFromPolicy != INFINITE)
- {
- ULONGLONG endTime = CLRGetTickCount64() + timeoutFromPolicy;
- if (abortType != EEPolicy::TA_Rude)
- {
- if (endTime < m_AbortEndTime)
- {
- m_AbortEndTime = endTime;
- }
- }
- else if (endTime < m_RudeAbortEndTime)
- {
- m_RudeAbortEndTime = endTime;
- }
- }
- }
-
if (abortInfo == (m_AbortInfo & abortInfo))
{
//