From 7cca75c8e95f129a21c33f1f4568e90e9e397f9d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 29 Jun 2022 10:28:53 -0500 Subject: Add AppWaitForSingleObject/MultipleObjects, ThreadWaitForCompletion. --- src/burn/engine/apply.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/burn/engine/apply.cpp') diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index e5b978f1..dd99a5cd 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp @@ -2333,6 +2333,8 @@ static HRESULT DoExecuteAction( HRESULT hr = S_OK; HANDLE rghWait[2] = { }; + DWORD dwSignaledIndex = 0; + DWORD dwExitCode = 0; BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; BOOL fRetry = FALSE; BOOL fStopWusaService = FALSE; @@ -2356,27 +2358,23 @@ static HRESULT DoExecuteAction( // wait for cache sync-point rghWait[0] = pExecuteAction->waitCachePackage.pPackage->hCacheEvent; rghWait[1] = pContext->pApplyContext->hCacheThread; - switch (::WaitForMultipleObjects(rghWait[1] ? 2 : 1, rghWait, FALSE, INFINITE)) + + hr = AppWaitForMultipleObjects(rghWait[1] ? 2 : 1, rghWait, FALSE, INFINITE, &dwSignaledIndex); + ExitOnFailure(hr, "Failed to wait for cache check-point."); + + switch (dwSignaledIndex) { - case WAIT_OBJECT_0: + case 0: break; - - case WAIT_OBJECT_0 + 1: - if (!::GetExitCodeThread(pContext->pApplyContext->hCacheThread, (DWORD*)&hr)) + case 1: + if (!::GetExitCodeThread(pContext->pApplyContext->hCacheThread, &dwExitCode)) { ExitWithLastError(hr, "Failed to get cache thread exit code."); } - if (SUCCEEDED(hr)) - { - hr = E_UNEXPECTED; - } - ExitOnFailure(hr, "Cache thread exited unexpectedly."); - - case WAIT_FAILED: __fallthrough; - default: - ExitWithLastError(hr, "Failed to wait for cache check-point."); + ExitWithRootFailure(hr, E_UNEXPECTED, "Cache thread exited unexpectedly with exit code: %u.", dwExitCode); } + break; case BURN_EXECUTE_ACTION_TYPE_RELATED_BUNDLE: -- cgit v1.2.3-55-g6feb