From 90d1109bfee9d426b86d36ae1131efc81f10480e Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 29 Aug 2008 19:06:04 +0000 Subject: [PATCH] - winsetup: Change the delete file after reboot code to use MoveFileEx instead of the RunOnce registry key. It does what I was originally trying to do directly to: HKLM\SYSTEM\CurrentControlSet\Control\ Session Manager\PendingFileRenameOperations But I ran into issues across various versions of Windows. Thanks to Nicolas Alvarez for pointing out the API. - scrsave: Some more screensaver clean-up. - lib: Fix an infinate loop problem in get_exit_status, luckly BOINC wasn't using it. clientscr/ screensaver.cpp lib/ util.C win_build/installerv2/redist/Windows/src/boinccas/ CAValidateRebootRequest.cpp svn path=/trunk/boinc/; revision=15945 --- checkin_notes | 20 ++++++++++ clientscr/screensaver.cpp | 27 +++++-------- lib/util.C | 2 + .../src/boinccas/CAValidateRebootRequest.cpp | 40 +------------------ 4 files changed, 33 insertions(+), 56 deletions(-) diff --git a/checkin_notes b/checkin_notes index b8a9562bad..864805783c 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7090,3 +7090,23 @@ David 28 Aug 2008 client/ app_start.C + +Rom 29 Aug 2008 + - winsetup: Change the delete file after reboot code to use + MoveFileEx instead of the RunOnce registry key. It does what + I was originally trying to do directly to: + HKLM\SYSTEM\CurrentControlSet\Control\ + Session Manager\PendingFileRenameOperations + But I ran into issues across various versions of Windows. + + Thanks to Nicolas Alvarez for pointing out the API. + - scrsave: Some more screensaver clean-up. + - lib: Fix an infinate loop problem in get_exit_status, + luckly BOINC wasn't using it. + + clientscr/ + screensaver.cpp + lib/ + util.C + win_build/installerv2/redist/Windows/src/boinccas/ + CAValidateRebootRequest.cpp diff --git a/clientscr/screensaver.cpp b/clientscr/screensaver.cpp index 20cf0a4139..5ecad640f5 100644 --- a/clientscr/screensaver.cpp +++ b/clientscr/screensaver.cpp @@ -327,12 +327,12 @@ void *CScreensaver::DataManagementProc() { while (true) { for (int i = 0; i < 4; i++) { - // *** - // *** Things that should be run frequently. - // *** 4 times per second. - // *** + // *** + // *** Things that should be run frequently. + // *** 4 times per second. + // *** - // Are we supposed to exit the screensaver? + // Are we supposed to exit the screensaver? if (m_QuitDataManagementProc) { // If main thread has requested we exit if (m_hGraphicsApplication || graphics_app_result_ptr) { terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr); @@ -514,27 +514,18 @@ void *CScreensaver::DataManagementProc() { // Is the graphics app still running? if (m_hGraphicsApplication) { -#ifdef _WIN32 - DWORD dwStatus = STILL_ACTIVE; - BOOL bRetVal = FALSE; - bRetVal = GetExitCodeProcess(m_hGraphicsApplication, &dwStatus); - BOINCTRACE(_T("CScreensaver::DataManagementProc - GetExitCodeProcess RetVal = '%d', Status = '%d'\n"), bRetVal, dwStatus); - if (bRetVal && (dwStatus != STILL_ACTIVE)) { + if (!process_exists(m_hGraphicsApplication)) { // Something has happened to the previously selected screensaver // application. Start a different one. + BOINCTRACE(_T("CScreensaver::DataManagementProc - Graphics application isn't running, start a new one.\n")); m_hGraphicsApplication = 0; graphics_app_result_ptr = NULL; continue; } else { +#ifdef _WIN32 CheckForegroundWindow(); - } -#else - if (waitpid(m_hGraphicsApplication, 0, WNOHANG) == m_hGraphicsApplication) { - m_hGraphicsApplication = 0; - graphics_app_result_ptr = NULL; - continue; - } #endif + } } } #endif // ! SIMULATE_NO_GRAPHICS diff --git a/lib/util.C b/lib/util.C index d4a5be09ce..29d3c2baf4 100644 --- a/lib/util.C +++ b/lib/util.C @@ -440,6 +440,8 @@ int get_exit_status(HANDLE pid_handle) { if (GetExitCodeProcess(pid_handle, &status)) { if (status == STILL_ACTIVE) { boinc_sleep(1); + } else { + break; } } } diff --git a/win_build/installerv2/redist/Windows/src/boinccas/CAValidateRebootRequest.cpp b/win_build/installerv2/redist/Windows/src/boinccas/CAValidateRebootRequest.cpp index f4c3851237..78ed957f45 100644 --- a/win_build/installerv2/redist/Windows/src/boinccas/CAValidateRebootRequest.cpp +++ b/win_build/installerv2/redist/Windows/src/boinccas/CAValidateRebootRequest.cpp @@ -70,9 +70,6 @@ UINT CAValidateRebootRequest::OnExecution() uiReturnValue = GetProperty( _T("INSTALLDIR"), strInstallDirectory ); if ( uiReturnValue ) return uiReturnValue; - uiReturnValue = GetProperty( _T("RETURN_REBOOTREQUESTED"), strRebootRequested ); - if ( uiReturnValue ) return uiReturnValue; - // Create reboot pending file // @@ -82,43 +79,10 @@ UINT CAValidateRebootRequest::OnExecution() if (fRebootPending) fclose(fRebootPending); - // Create a registry key to delete the RebootInProgress.txt flag - // file on a reboot. + // Schedule the file for deletion after a reboot. // - if ( _T("1") == strRebootRequested ) - { - LONG lReturnValue; - HKEY hkSetupHive; + MoveFileEx(strRebootPendingFilename.c_str(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT); - lReturnValue = RegCreateKeyEx( - HKEY_LOCAL_MACHINE, - _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"), - 0, - NULL, - REG_OPTION_NON_VOLATILE, - KEY_READ | KEY_WRITE, - NULL, - &hkSetupHive, - NULL - ); - if (lReturnValue == ERROR_SUCCESS) - { - tstring strCommand; - - strCommand = _T("cmd.exe /c \"del \"") + strRebootPendingFilename + _T("\"\""); - - RegSetValueEx( - hkSetupHive, - _T("*BOINCRebootPendingCleanup"), - 0, - REG_SZ, - (CONST BYTE *)strCommand.c_str(), - (DWORD)(strCommand.size()*sizeof(TCHAR)) - ); - - RegCloseKey(hkSetupHive); - } - } return ERROR_SUCCESS; }