diff options
Diffstat (limited to 'src/burn/engine/apply.cpp')
-rw-r--r-- | src/burn/engine/apply.cpp | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index f0b78e81..b4fa9dac 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp | |||
@@ -56,11 +56,11 @@ typedef struct _BURN_CACHE_PROGRESS_CONTEXT | |||
56 | typedef struct _BURN_EXECUTE_CONTEXT | 56 | typedef struct _BURN_EXECUTE_CONTEXT |
57 | { | 57 | { |
58 | BURN_USER_EXPERIENCE* pUX; | 58 | BURN_USER_EXPERIENCE* pUX; |
59 | BURN_APPLY_CONTEXT* pApplyContext; | ||
59 | BOOL fRollback; | 60 | BOOL fRollback; |
60 | BURN_PACKAGE* pExecutingPackage; | 61 | BURN_PACKAGE* pExecutingPackage; |
61 | DWORD cExecutedPackages; | 62 | DWORD cExecutedPackages; |
62 | DWORD cExecutePackagesTotal; | 63 | DWORD cExecutePackagesTotal; |
63 | DWORD* pcOverallProgressTicks; | ||
64 | } BURN_EXECUTE_CONTEXT; | 64 | } BURN_EXECUTE_CONTEXT; |
65 | 65 | ||
66 | 66 | ||
@@ -187,7 +187,6 @@ static void DoRollbackCache( | |||
187 | static HRESULT DoExecuteAction( | 187 | static HRESULT DoExecuteAction( |
188 | __in BURN_ENGINE_STATE* pEngineState, | 188 | __in BURN_ENGINE_STATE* pEngineState, |
189 | __in BURN_EXECUTE_ACTION* pExecuteAction, | 189 | __in BURN_EXECUTE_ACTION* pExecuteAction, |
190 | __in_opt HANDLE hCacheThread, | ||
191 | __in BURN_EXECUTE_CONTEXT* pContext, | 190 | __in BURN_EXECUTE_CONTEXT* pContext, |
192 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary, | 191 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary, |
193 | __inout BURN_EXECUTE_ACTION_CHECKPOINT** ppCheckpoint, | 192 | __inout BURN_EXECUTE_ACTION_CHECKPOINT** ppCheckpoint, |
@@ -284,7 +283,7 @@ static HRESULT ReportOverallProgressTicks( | |||
284 | __in BURN_USER_EXPERIENCE* pUX, | 283 | __in BURN_USER_EXPERIENCE* pUX, |
285 | __in BOOL fRollback, | 284 | __in BOOL fRollback, |
286 | __in DWORD cOverallProgressTicksTotal, | 285 | __in DWORD cOverallProgressTicksTotal, |
287 | __in DWORD cOverallProgressTicks | 286 | __in BURN_APPLY_CONTEXT* pApplyContext |
288 | ); | 287 | ); |
289 | static HRESULT ExecutePackageComplete( | 288 | static HRESULT ExecutePackageComplete( |
290 | __in BURN_USER_EXPERIENCE* pUX, | 289 | __in BURN_USER_EXPERIENCE* pUX, |
@@ -499,8 +498,7 @@ extern "C" HRESULT ApplyCache( | |||
499 | __in BURN_VARIABLES* pVariables, | 498 | __in BURN_VARIABLES* pVariables, |
500 | __in BURN_PLAN* pPlan, | 499 | __in BURN_PLAN* pPlan, |
501 | __in HANDLE hPipe, | 500 | __in HANDLE hPipe, |
502 | __inout DWORD* pcOverallProgressTicks, | 501 | __in BURN_APPLY_CONTEXT* pContext |
503 | __inout BOOL* pfRollback | ||
504 | ) | 502 | ) |
505 | { | 503 | { |
506 | HRESULT hr = S_OK; | 504 | HRESULT hr = S_OK; |
@@ -508,8 +506,6 @@ extern "C" HRESULT ApplyCache( | |||
508 | BURN_CACHE_CONTEXT cacheContext = { }; | 506 | BURN_CACHE_CONTEXT cacheContext = { }; |
509 | BURN_PACKAGE* pPackage = NULL; | 507 | BURN_PACKAGE* pPackage = NULL; |
510 | 508 | ||
511 | *pfRollback = FALSE; | ||
512 | |||
513 | hr = UserExperienceOnCacheBegin(pUX); | 509 | hr = UserExperienceOnCacheBegin(pUX); |
514 | ExitOnRootFailure(hr, "BA aborted cache."); | 510 | ExitOnRootFailure(hr, "BA aborted cache."); |
515 | 511 | ||
@@ -539,9 +535,7 @@ extern "C" HRESULT ApplyCache( | |||
539 | hr = ApplyLayoutBundle(&cacheContext, pCacheAction->bundleLayout.pPayloadGroup, pCacheAction->bundleLayout.sczExecutableName, pCacheAction->bundleLayout.sczUnverifiedPath, pCacheAction->bundleLayout.qwBundleSize); | 535 | hr = ApplyLayoutBundle(&cacheContext, pCacheAction->bundleLayout.pPayloadGroup, pCacheAction->bundleLayout.sczExecutableName, pCacheAction->bundleLayout.sczUnverifiedPath, pCacheAction->bundleLayout.qwBundleSize); |
540 | ExitOnFailure(hr, "Failed cache action: %ls", L"layout bundle"); | 536 | ExitOnFailure(hr, "Failed cache action: %ls", L"layout bundle"); |
541 | 537 | ||
542 | ++(*pcOverallProgressTicks); | 538 | hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext); |
543 | |||
544 | hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, *pcOverallProgressTicks); | ||
545 | LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"layout bundle"); | 539 | LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"layout bundle"); |
546 | 540 | ||
547 | break; | 541 | break; |
@@ -567,9 +561,7 @@ extern "C" HRESULT ApplyCache( | |||
567 | hr = ApplyCachePackage(&cacheContext, pPackage); | 561 | hr = ApplyCachePackage(&cacheContext, pPackage); |
568 | ExitOnFailure(hr, "Failed cache action: %ls", L"cache package"); | 562 | ExitOnFailure(hr, "Failed cache action: %ls", L"cache package"); |
569 | 563 | ||
570 | ++(*pcOverallProgressTicks); | 564 | hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext); |
571 | |||
572 | hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, *pcOverallProgressTicks); | ||
573 | LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"cache package"); | 565 | LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"cache package"); |
574 | 566 | ||
575 | break; | 567 | break; |
@@ -598,7 +590,7 @@ LExit: | |||
598 | if (FAILED(hr)) | 590 | if (FAILED(hr)) |
599 | { | 591 | { |
600 | DoRollbackCache(pUX, pPlan, hPipe, dwCheckpoint); | 592 | DoRollbackCache(pUX, pPlan, hPipe, dwCheckpoint); |
601 | *pfRollback = TRUE; | 593 | pContext->fRollback = TRUE; |
602 | } | 594 | } |
603 | 595 | ||
604 | // Clean up any remanents in the cache. | 596 | // Clean up any remanents in the cache. |
@@ -622,9 +614,7 @@ LExit: | |||
622 | 614 | ||
623 | extern "C" HRESULT ApplyExecute( | 615 | extern "C" HRESULT ApplyExecute( |
624 | __in BURN_ENGINE_STATE* pEngineState, | 616 | __in BURN_ENGINE_STATE* pEngineState, |
625 | __in_opt HANDLE hCacheThread, | 617 | __in BURN_APPLY_CONTEXT* pApplyContext, |
626 | __inout DWORD* pcOverallProgressTicks, | ||
627 | __out BOOL* pfRollback, | ||
628 | __out BOOL* pfSuspend, | 618 | __out BOOL* pfSuspend, |
629 | __out BOOTSTRAPPER_APPLY_RESTART* pRestart | 619 | __out BOOTSTRAPPER_APPLY_RESTART* pRestart |
630 | ) | 620 | ) |
@@ -637,10 +627,9 @@ extern "C" HRESULT ApplyExecute( | |||
637 | BOOL fSeekNextRollbackBoundary = FALSE; | 627 | BOOL fSeekNextRollbackBoundary = FALSE; |
638 | 628 | ||
639 | context.pUX = &pEngineState->userExperience; | 629 | context.pUX = &pEngineState->userExperience; |
630 | context.pApplyContext = pApplyContext; | ||
640 | context.cExecutePackagesTotal = pEngineState->plan.cExecutePackagesTotal; | 631 | context.cExecutePackagesTotal = pEngineState->plan.cExecutePackagesTotal; |
641 | context.pcOverallProgressTicks = pcOverallProgressTicks; | ||
642 | 632 | ||
643 | *pfRollback = FALSE; | ||
644 | *pfSuspend = FALSE; | 633 | *pfSuspend = FALSE; |
645 | 634 | ||
646 | // Send execute begin to BA. | 635 | // Send execute begin to BA. |
@@ -670,7 +659,7 @@ extern "C" HRESULT ApplyExecute( | |||
670 | } | 659 | } |
671 | 660 | ||
672 | // Execute the action. | 661 | // Execute the action. |
673 | hr = DoExecuteAction(pEngineState, pExecuteAction, hCacheThread, &context, &pRollbackBoundary, &pCheckpoint, pfSuspend, pRestart); | 662 | hr = DoExecuteAction(pEngineState, pExecuteAction, &context, &pRollbackBoundary, &pCheckpoint, pfSuspend, pRestart); |
674 | 663 | ||
675 | if (*pfSuspend || BOOTSTRAPPER_APPLY_RESTART_INITIATED == *pRestart) | 664 | if (*pfSuspend || BOOTSTRAPPER_APPLY_RESTART_INITIATED == *pRestart) |
676 | { | 665 | { |
@@ -698,7 +687,7 @@ extern "C" HRESULT ApplyExecute( | |||
698 | IgnoreRollbackError(hrRollback, "Failed commit transaction from disable rollback"); | 687 | IgnoreRollbackError(hrRollback, "Failed commit transaction from disable rollback"); |
699 | } | 688 | } |
700 | 689 | ||
701 | *pfRollback = TRUE; | 690 | pApplyContext->fRollback = TRUE; |
702 | break; | 691 | break; |
703 | } | 692 | } |
704 | 693 | ||
@@ -719,7 +708,7 @@ extern "C" HRESULT ApplyExecute( | |||
719 | // If the rollback boundary is vital, end execution here. | 708 | // If the rollback boundary is vital, end execution here. |
720 | if (pRollbackBoundary && pRollbackBoundary->fVital) | 709 | if (pRollbackBoundary && pRollbackBoundary->fVital) |
721 | { | 710 | { |
722 | *pfRollback = TRUE; | 711 | pApplyContext->fRollback = TRUE; |
723 | break; | 712 | break; |
724 | } | 713 | } |
725 | 714 | ||
@@ -2163,7 +2152,6 @@ static void DoRollbackCache( | |||
2163 | static HRESULT DoExecuteAction( | 2152 | static HRESULT DoExecuteAction( |
2164 | __in BURN_ENGINE_STATE* pEngineState, | 2153 | __in BURN_ENGINE_STATE* pEngineState, |
2165 | __in BURN_EXECUTE_ACTION* pExecuteAction, | 2154 | __in BURN_EXECUTE_ACTION* pExecuteAction, |
2166 | __in_opt HANDLE hCacheThread, | ||
2167 | __in BURN_EXECUTE_CONTEXT* pContext, | 2155 | __in BURN_EXECUTE_CONTEXT* pContext, |
2168 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary, | 2156 | __inout BURN_ROLLBACK_BOUNDARY** ppRollbackBoundary, |
2169 | __inout BURN_EXECUTE_ACTION_CHECKPOINT** ppCheckpoint, | 2157 | __inout BURN_EXECUTE_ACTION_CHECKPOINT** ppCheckpoint, |
@@ -2195,14 +2183,14 @@ static HRESULT DoExecuteAction( | |||
2195 | case BURN_EXECUTE_ACTION_TYPE_WAIT_SYNCPOINT: | 2183 | case BURN_EXECUTE_ACTION_TYPE_WAIT_SYNCPOINT: |
2196 | // wait for cache sync-point | 2184 | // wait for cache sync-point |
2197 | rghWait[0] = pExecuteAction->syncpoint.hEvent; | 2185 | rghWait[0] = pExecuteAction->syncpoint.hEvent; |
2198 | rghWait[1] = hCacheThread; | 2186 | rghWait[1] = pContext->pApplyContext->hCacheThread; |
2199 | switch (::WaitForMultipleObjects(rghWait[1] ? 2 : 1, rghWait, FALSE, INFINITE)) | 2187 | switch (::WaitForMultipleObjects(rghWait[1] ? 2 : 1, rghWait, FALSE, INFINITE)) |
2200 | { | 2188 | { |
2201 | case WAIT_OBJECT_0: | 2189 | case WAIT_OBJECT_0: |
2202 | break; | 2190 | break; |
2203 | 2191 | ||
2204 | case WAIT_OBJECT_0 + 1: | 2192 | case WAIT_OBJECT_0 + 1: |
2205 | if (!::GetExitCodeThread(hCacheThread, (DWORD*)&hr)) | 2193 | if (!::GetExitCodeThread(pContext->pApplyContext->hCacheThread, (DWORD*)&hr)) |
2206 | { | 2194 | { |
2207 | ExitWithLastError(hr, "Failed to get cache thread exit code."); | 2195 | ExitWithLastError(hr, "Failed to get cache thread exit code."); |
2208 | } | 2196 | } |
@@ -2449,9 +2437,8 @@ static HRESULT ExecuteExePackage( | |||
2449 | ExitOnRootFailure(hr, "BA aborted EXE progress."); | 2437 | ExitOnRootFailure(hr, "BA aborted EXE progress."); |
2450 | 2438 | ||
2451 | pContext->cExecutedPackages += fRollback ? -1 : 1; | 2439 | pContext->cExecutedPackages += fRollback ? -1 : 1; |
2452 | (*pContext->pcOverallProgressTicks) += fRollback ? -1 : 1; | ||
2453 | 2440 | ||
2454 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, *pContext->pcOverallProgressTicks); | 2441 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, pContext->pApplyContext); |
2455 | ExitOnRootFailure(hr, "BA aborted EXE package execute progress."); | 2442 | ExitOnRootFailure(hr, "BA aborted EXE package execute progress."); |
2456 | 2443 | ||
2457 | LExit: | 2444 | LExit: |
@@ -2514,9 +2501,8 @@ static HRESULT ExecuteMsiPackage( | |||
2514 | } | 2501 | } |
2515 | 2502 | ||
2516 | pContext->cExecutedPackages += fRollback ? -1 : 1; | 2503 | pContext->cExecutedPackages += fRollback ? -1 : 1; |
2517 | (*pContext->pcOverallProgressTicks) += fRollback ? -1 : 1; | ||
2518 | 2504 | ||
2519 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, *pContext->pcOverallProgressTicks); | 2505 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, pContext->pApplyContext); |
2520 | ExitOnRootFailure(hr, "BA aborted MSI package execute progress."); | 2506 | ExitOnRootFailure(hr, "BA aborted MSI package execute progress."); |
2521 | 2507 | ||
2522 | LExit: | 2508 | LExit: |
@@ -2588,9 +2574,8 @@ static HRESULT ExecuteMspPackage( | |||
2588 | } | 2574 | } |
2589 | 2575 | ||
2590 | pContext->cExecutedPackages += fRollback ? -1 : 1; | 2576 | pContext->cExecutedPackages += fRollback ? -1 : 1; |
2591 | (*pContext->pcOverallProgressTicks) += fRollback ? -1 : 1; | ||
2592 | 2577 | ||
2593 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, *pContext->pcOverallProgressTicks); | 2578 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, pContext->pApplyContext); |
2594 | ExitOnRootFailure(hr, "BA aborted MSP package execute progress."); | 2579 | ExitOnRootFailure(hr, "BA aborted MSP package execute progress."); |
2595 | 2580 | ||
2596 | LExit: | 2581 | LExit: |
@@ -2669,9 +2654,8 @@ static HRESULT ExecuteMsuPackage( | |||
2669 | ExitOnRootFailure(hr, "BA aborted MSU progress."); | 2654 | ExitOnRootFailure(hr, "BA aborted MSU progress."); |
2670 | 2655 | ||
2671 | pContext->cExecutedPackages += fRollback ? -1 : 1; | 2656 | pContext->cExecutedPackages += fRollback ? -1 : 1; |
2672 | (*pContext->pcOverallProgressTicks) += fRollback ? -1 : 1; | ||
2673 | 2657 | ||
2674 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, *pContext->pcOverallProgressTicks); | 2658 | hr = ReportOverallProgressTicks(&pEngineState->userExperience, fRollback, pEngineState->plan.cOverallProgressTicksTotal, pContext->pApplyContext); |
2675 | ExitOnRootFailure(hr, "BA aborted MSU package execute progress."); | 2659 | ExitOnRootFailure(hr, "BA aborted MSU package execute progress."); |
2676 | 2660 | ||
2677 | LExit: | 2661 | LExit: |
@@ -3040,15 +3024,23 @@ static HRESULT ReportOverallProgressTicks( | |||
3040 | __in BURN_USER_EXPERIENCE* pUX, | 3024 | __in BURN_USER_EXPERIENCE* pUX, |
3041 | __in BOOL fRollback, | 3025 | __in BOOL fRollback, |
3042 | __in DWORD cOverallProgressTicksTotal, | 3026 | __in DWORD cOverallProgressTicksTotal, |
3043 | __in DWORD cOverallProgressTicks | 3027 | __in BURN_APPLY_CONTEXT* pApplyContext |
3044 | ) | 3028 | ) |
3045 | { | 3029 | { |
3046 | HRESULT hr = S_OK; | 3030 | HRESULT hr = S_OK; |
3047 | DWORD dwProgress = cOverallProgressTicksTotal ? (cOverallProgressTicks * 100 / cOverallProgressTicksTotal) : 0; | 3031 | DWORD dwProgress = 0; |
3032 | |||
3033 | ::EnterCriticalSection(&pApplyContext->csApply); | ||
3034 | |||
3035 | pApplyContext->cOverallProgressTicks += fRollback ? -1 : 1; | ||
3036 | |||
3037 | dwProgress = cOverallProgressTicksTotal ? (pApplyContext->cOverallProgressTicks * 100 / cOverallProgressTicksTotal) : 0; | ||
3048 | 3038 | ||
3049 | // TODO: consider sending different progress numbers in the future. | 3039 | // TODO: consider sending different progress numbers in the future. |
3050 | hr = UserExperienceOnProgress(pUX, fRollback, dwProgress, dwProgress); | 3040 | hr = UserExperienceOnProgress(pUX, fRollback, dwProgress, dwProgress); |
3051 | 3041 | ||
3042 | ::LeaveCriticalSection(&pApplyContext->csApply); | ||
3043 | |||
3052 | return hr; | 3044 | return hr; |
3053 | } | 3045 | } |
3054 | 3046 | ||