diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2015-10-15 17:13:38 -0700 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2015-10-15 17:13:38 -0700 |
commit | 99b114653c3f3e3378da2448c0c6b132aa48ffe5 (patch) | |
tree | 27b9210403bed0525192d24b962c28fb17e4f19a /src/pal/src/init | |
parent | 1a729f8c93d03e305a1d830c9e65ca05185adcd1 (diff) | |
download | coreclr-99b114653c3f3e3378da2448c0c6b132aa48ffe5.tar.gz coreclr-99b114653c3f3e3378da2448c0c6b132aa48ffe5.tar.bz2 coreclr-99b114653c3f3e3378da2448c0c6b132aa48ffe5.zip |
Remove unused step logic from PALCommonCleanup.
Diffstat (limited to 'src/pal/src/init')
-rw-r--r-- | src/pal/src/init/pal.cpp | 125 |
1 files changed, 16 insertions, 109 deletions
diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp index d4a52b5432..7745b93d96 100644 --- a/src/pal/src/init/pal.cpp +++ b/src/pal/src/init/pal.cpp @@ -754,128 +754,35 @@ Parameters : TRUE: full cleanup --*/ void -PALCommonCleanup(PALCLEANUP_STEP step, BOOL full_cleanup) +PALCommonCleanup(BOOL full_cleanup) { CPalThread *pThread = InternalGetCurrentThread(); - static int step_done[PALCLEANUP_STEP_INVALID] = { 0 }; + static bool done = false; - switch (step) + if (!done) { - case PALCLEANUP_ALL_STEPS: - case PALCLEANUP_STEP_ONE: - /* Note: in order to work correctly, this step should be executed with - init_count > 0 - */ - if (!step_done[PALCLEANUP_STEP_ONE]) - { - step_done[PALCLEANUP_STEP_ONE] = 1; + done = true; - PALSetShutdownIntent(); + PALSetShutdownIntent(); - // - // Let the synchronization manager know we're about to shutdown - // + // + // Let the synchronization manager know we're about to shutdown + // - CPalSynchMgrController::PrepareForShutdown(); + CPalSynchMgrController::PrepareForShutdown(); #ifdef _DEBUG - PROCDumpThreadList(); + PROCDumpThreadList(); #endif - TRACE("About to suspend every other thread\n"); + TRACE("About to suspend every other thread\n"); - /* prevent other threads from acquiring signaled objects */ - PROCCondemnOtherThreads(); - /* prevent other threads from using services we're shutting down */ - PROCSuspendOtherThreads(); - - TRACE("Every other thread suspended until exit\n"); - } - - /* Fall down for PALCLEANUP_ALL_STEPS */ - if (PALCLEANUP_ALL_STEPS != step) - break; - - case PALCLEANUP_STEP_TWO: - if (!step_done[PALCLEANUP_STEP_TWO]) - { - step_done[PALCLEANUP_STEP_TWO] = 1; - - /* LOADFreeeModules needs to be called before unitializing the rest - of the PAL since it could result in calling DllMain for loaded - libraries. For the user DllMain, all PAL APIs should still be - functional. */ - LOADFreeModules(FALSE); - -#ifdef PAL_PERF - PERFDisableProcessProfile(); - PERFDisableThreadProfile(FALSE); - PERFTerminate(); -#endif - - if (full_cleanup) - { - /* close primary handles of standard file objects */ - FILECleanupStdHandles(); - VIRTUALCleanup(); - /* SEH requires information from the process structure to work; - LOADFreeModules requires SEH to be functional when calling DllMain. - Therefore SEHCleanup must go between LOADFreeModules and - PROCCleanupInitialProcess */ - SEHCleanup(); - PROCCleanupInitialProcess(); - } - - // Object manager shutdown may cause all CPalThread objects - // to be deleted. Since the CPalThread of the shutdown thread - // needs to be available for reference by the thread suspension unsafe - // operations, the reference of CPalThread is incremented here - // to keep it alive until PAL finishes cleanup. - pThread->AddThreadReference(); - - // - // Shutdown object manager -- this needs to happen before the - // synch manager shutdown since it will call into the synch - // manager to free object synch data - // - static_cast<CSharedMemoryObjectManager*>(g_pObjectManager)->Shutdown(pThread); - - // - // Final synch manager shutdown - // - CPalSynchMgrController::Shutdown(pThread, full_cleanup); - - if (full_cleanup) - { - /* It needs to be done after stopping the handle manager, because - the cleanup will delete the critical section which is used - when closing the handle of a file mapping */ - MAPCleanup(); - // MutexCleanup(); - - MiscCleanup(); - - TLSCleanup(); - } - - // The thread object will no longer be available after the shutdown thread - // releases the thread reference. - g_fThreadDataAvailable = FALSE; - pThread->ReleaseThreadReference(); - pthread_setspecific(thObjKey, NULL); // Make sure any TLS entry is removed. - - // Since thread object is no longer available here, - // the code path from here should stop using any functions - // that reference thread object. - SHMCleanup(); - - TRACE("PAL Terminated.\n"); - } - break; + /* prevent other threads from acquiring signaled objects */ + PROCCondemnOtherThreads(); + /* prevent other threads from using services we're shutting down */ + PROCSuspendOtherThreads(); - default: - ASSERT("Unknown final cleanup step %d", step); - break; + TRACE("Every other thread suspended until exit\n"); } } |