Delete EEPolicy::GetTimeOut
authorJan Kotas <jkotas@microsoft.com>
Sat, 25 Apr 2020 06:24:54 +0000 (23:24 -0700)
committerJan Kotas <jkotas@microsoft.com>
Sat, 25 Apr 2020 13:53:06 +0000 (06:53 -0700)
src/coreclr/src/vm/ceemain.cpp
src/coreclr/src/vm/eepolicy.cpp
src/coreclr/src/vm/eepolicy.h
src/coreclr/src/vm/threadsuspend.cpp

index 5f7965e..e835cc6 100644 (file)
@@ -1156,70 +1156,6 @@ void ForceEEShutdown(ShutdownCompleteAction sca)
     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{
@@ -1240,7 +1176,7 @@ void WaitForEndOfShutdown()
         pThread->SetThreadStateNC(Thread::TSNC_BlockedForShutdown);
     }
 
-    while (!WaitForEndOfShutdown_OneIteration());
+    for (;;) g_pEEShutDownEvent->Wait(INFINITE, TRUE);
 }
 
 // ---------------------------------------------------------------------------
index 3ffd0ab..0bc68db 100644 (file)
@@ -70,9 +70,6 @@ EEPolicy::EEPolicy ()
     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;
 }
 
index a96bfa8..a1e74c0 100644 (file)
@@ -33,13 +33,6 @@ public:
 
     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;
index d5a5739..907e4ec 100644 (file)
@@ -1301,19 +1301,7 @@ Thread::UserAbort(ThreadAbortRequester requester,
             _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);
@@ -1395,18 +1383,15 @@ LRetry:
             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)
@@ -1415,10 +1400,6 @@ LRetry:
                     // Debugger can call this function to about func-eval with a timeout
                     return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
                 }
-                if (timeout1 != INFINITE)
-                {
-                    break;
-                }
             }
         }
 
@@ -1915,20 +1896,7 @@ LPrepareRetry:
 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;
@@ -2011,34 +1979,6 @@ void Thread::MarkThreadForAbort(ThreadAbortRequester requester, EEPolicy::Thread
         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))
     {
         //