aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/apply.cpp
diff options
context:
space:
mode:
authorNir Bar <nir.bar@panel-sw.co.il>2022-12-06 13:22:41 +0200
committerSean Hall <r.sean.hall@gmail.com>2022-12-12 21:50:39 -0600
commit50e24e9cf2084b6cb67b5d8fc509163061408bb6 (patch)
tree05c9df57480eb6308c3462c13847b43288f9dbb4 /src/burn/engine/apply.cpp
parentc54f3083489827a1e57c6fd7f3d76f62ddc6e85e (diff)
downloadwix-50e24e9cf2084b6cb67b5d8fc509163061408bb6.tar.gz
wix-50e24e9cf2084b6cb67b5d8fc509163061408bb6.tar.bz2
wix-50e24e9cf2084b6cb67b5d8fc509163061408bb6.zip
Use MSI transaction end result to detect whether reboot is needed
Diffstat (limited to 'src/burn/engine/apply.cpp')
-rw-r--r--src/burn/engine/apply.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp
index 8fbaa76e..9a1a7bf9 100644
--- a/src/burn/engine/apply.cpp
+++ b/src/burn/engine/apply.cpp
@@ -300,12 +300,14 @@ static HRESULT ExecuteMsiBeginTransaction(
300static HRESULT ExecuteMsiCommitTransaction( 300static HRESULT ExecuteMsiCommitTransaction(
301 __in BURN_ENGINE_STATE* pEngineState, 301 __in BURN_ENGINE_STATE* pEngineState,
302 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary, 302 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
303 __in BURN_EXECUTE_CONTEXT* pContext 303 __in BURN_EXECUTE_CONTEXT* pContext,
304 __out BOOTSTRAPPER_APPLY_RESTART *pRestart
304 ); 305 );
305static HRESULT ExecuteMsiRollbackTransaction( 306static HRESULT ExecuteMsiRollbackTransaction(
306 __in BURN_ENGINE_STATE* pEngineState, 307 __in BURN_ENGINE_STATE* pEngineState,
307 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary, 308 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
308 __in BURN_EXECUTE_CONTEXT* pContext 309 __in BURN_EXECUTE_CONTEXT* pContext,
310 __out BOOTSTRAPPER_APPLY_RESTART *pRestart
309 ); 311 );
310static void ResetTransactionRegistrationState( 312static void ResetTransactionRegistrationState(
311 __in BURN_ENGINE_STATE* pEngineState, 313 __in BURN_ENGINE_STATE* pEngineState,
@@ -645,7 +647,7 @@ extern "C" HRESULT ApplyCache(
645 Assert(pPlan->sczLayoutDirectory); 647 Assert(pPlan->sczLayoutDirectory);
646 hr = ApplyLayoutContainer(&cacheContext, pCacheAction->container.pContainer); 648 hr = ApplyLayoutContainer(&cacheContext, pCacheAction->container.pContainer);
647 ExitOnFailure(hr, "Failed cache action: %ls", L"layout container"); 649 ExitOnFailure(hr, "Failed cache action: %ls", L"layout container");
648 650
649 break; 651 break;
650 652
651 case BURN_CACHE_ACTION_TYPE_SIGNAL_SYNCPOINT: 653 case BURN_CACHE_ACTION_TYPE_SIGNAL_SYNCPOINT:
@@ -793,7 +795,7 @@ extern "C" HRESULT ApplyExecute(
793 795
794 if (pCheckpoint && pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction) 796 if (pCheckpoint && pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction)
795 { 797 {
796 hrRollback = ExecuteMsiCommitTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context); 798 hrRollback = ExecuteMsiCommitTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context, pRestart);
797 IgnoreRollbackError(hrRollback, "Failed commit transaction from disable rollback"); 799 IgnoreRollbackError(hrRollback, "Failed commit transaction from disable rollback");
798 } 800 }
799 801
@@ -806,7 +808,7 @@ extern "C" HRESULT ApplyExecute(
806 // If inside a MSI transaction, roll it back. 808 // If inside a MSI transaction, roll it back.
807 if (pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction) 809 if (pCheckpoint->pActiveRollbackBoundary && pCheckpoint->pActiveRollbackBoundary->fActiveTransaction)
808 { 810 {
809 hrRollback = ExecuteMsiRollbackTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context); 811 hrRollback = ExecuteMsiRollbackTransaction(pEngineState, pCheckpoint->pActiveRollbackBoundary, &context, pRestart);
810 IgnoreRollbackError(hrRollback, "Failed rolling back transaction"); 812 IgnoreRollbackError(hrRollback, "Failed rolling back transaction");
811 } 813 }
812 814
@@ -2058,13 +2060,13 @@ static HRESULT DownloadPayload(
2058 cacheCallback.pfnProgress = CacheProgressRoutine; 2060 cacheCallback.pfnProgress = CacheProgressRoutine;
2059 cacheCallback.pfnCancel = NULL; // TODO: set this 2061 cacheCallback.pfnCancel = NULL; // TODO: set this
2060 cacheCallback.pv = pProgress; 2062 cacheCallback.pv = pProgress;
2061 2063
2062 authenticationData.pUX = pProgress->pCacheContext->pUX; 2064 authenticationData.pUX = pProgress->pCacheContext->pUX;
2063 authenticationData.wzPackageOrContainerId = wzPackageOrContainerId; 2065 authenticationData.wzPackageOrContainerId = wzPackageOrContainerId;
2064 authenticationData.wzPayloadId = wzPayloadId; 2066 authenticationData.wzPayloadId = wzPayloadId;
2065 authenticationCallback.pv = static_cast<LPVOID>(&authenticationData); 2067 authenticationCallback.pv = static_cast<LPVOID>(&authenticationData);
2066 authenticationCallback.pfnAuthenticate = &AuthenticationRequired; 2068 authenticationCallback.pfnAuthenticate = &AuthenticationRequired;
2067 2069
2068 hr = DownloadUrl(pDownloadSource, qwDownloadSize, wzDestinationPath, &cacheCallback, &authenticationCallback); 2070 hr = DownloadUrl(pDownloadSource, qwDownloadSize, wzDestinationPath, &cacheCallback, &authenticationCallback);
2069 ExitOnFailure(hr, "Failed attempt to download URL: '%ls' to: '%ls'", pDownloadSource->sczUrl, wzDestinationPath); 2071 ExitOnFailure(hr, "Failed attempt to download URL: '%ls' to: '%ls'", pDownloadSource->sczUrl, wzDestinationPath);
2070 2072
@@ -2526,7 +2528,7 @@ static HRESULT DoExecuteAction(
2526 break; 2528 break;
2527 2529
2528 case BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION: 2530 case BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION:
2529 hr = ExecuteMsiCommitTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext); 2531 hr = ExecuteMsiCommitTransaction(pEngineState, pExecuteAction->msiTransaction.pRollbackBoundary, pContext, &restart);
2530 ExitOnFailure(hr, "Failed to execute commit MSI transaction action."); 2532 ExitOnFailure(hr, "Failed to execute commit MSI transaction action.");
2531 break; 2533 break;
2532 2534
@@ -3381,11 +3383,13 @@ LExit:
3381static HRESULT ExecuteMsiCommitTransaction( 3383static HRESULT ExecuteMsiCommitTransaction(
3382 __in BURN_ENGINE_STATE* pEngineState, 3384 __in BURN_ENGINE_STATE* pEngineState,
3383 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary, 3385 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
3384 __in BURN_EXECUTE_CONTEXT* /*pContext*/ 3386 __in BURN_EXECUTE_CONTEXT* pContext,
3387 __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3385 ) 3388 )
3386{ 3389{
3387 HRESULT hr = S_OK; 3390 HRESULT hr = S_OK;
3388 BOOL fCommitBeginCalled = FALSE; 3391 BOOL fCommitBeginCalled = FALSE;
3392 BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action = BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE;
3389 3393
3390 if (!pRollbackBoundary->fActiveTransaction) 3394 if (!pRollbackBoundary->fActiveTransaction)
3391 { 3395 {
@@ -3398,12 +3402,12 @@ static HRESULT ExecuteMsiCommitTransaction(
3398 3402
3399 if (pEngineState->plan.fPerMachine) 3403 if (pEngineState->plan.fPerMachine)
3400 { 3404 {
3401 hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary); 3405 hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary, MsiExecuteMessageHandler, pContext, pRestart);
3402 ExitOnFailure(hr, "Failed to commit an elevated MSI transaction."); 3406 ExitOnFailure(hr, "Failed to commit an elevated MSI transaction.");
3403 } 3407 }
3404 else 3408 else
3405 { 3409 {
3406 hr = MsiEngineCommitTransaction(pRollbackBoundary); 3410 hr = MsiEngineCommitTransaction(pRollbackBoundary, pRestart);
3407 } 3411 }
3408 3412
3409 // Assume that MsiEndTransaction can only be called once for each MsiBeginTransaction. 3413 // Assume that MsiEndTransaction can only be called once for each MsiBeginTransaction.
@@ -3414,7 +3418,12 @@ static HRESULT ExecuteMsiCommitTransaction(
3414LExit: 3418LExit:
3415 if (fCommitBeginCalled) 3419 if (fCommitBeginCalled)
3416 { 3420 {
3417 UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); 3421 UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr, *pRestart, &action);
3422
3423 if (action == BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART)
3424 {
3425 *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
3426 }
3418 } 3427 }
3419 3428
3420 return hr; 3429 return hr;
@@ -3423,11 +3432,13 @@ LExit:
3423static HRESULT ExecuteMsiRollbackTransaction( 3432static HRESULT ExecuteMsiRollbackTransaction(
3424 __in BURN_ENGINE_STATE* pEngineState, 3433 __in BURN_ENGINE_STATE* pEngineState,
3425 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary, 3434 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary,
3426 __in BURN_EXECUTE_CONTEXT* /*pContext*/ 3435 __in BURN_EXECUTE_CONTEXT* pContext,
3436 __out BOOTSTRAPPER_APPLY_RESTART *pRestart
3427 ) 3437 )
3428{ 3438{
3429 HRESULT hr = S_OK; 3439 HRESULT hr = S_OK;
3430 BOOL fRollbackBeginCalled = FALSE; 3440 BOOL fRollbackBeginCalled = FALSE;
3441 BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action = BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_NONE;
3431 3442
3432 if (!pRollbackBoundary->fActiveTransaction) 3443 if (!pRollbackBoundary->fActiveTransaction)
3433 { 3444 {
@@ -3439,12 +3450,12 @@ static HRESULT ExecuteMsiRollbackTransaction(
3439 3450
3440 if (pEngineState->plan.fPerMachine) 3451 if (pEngineState->plan.fPerMachine)
3441 { 3452 {
3442 hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary); 3453 hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary, MsiExecuteMessageHandler, pContext, pRestart);
3443 ExitOnFailure(hr, "Failed to rollback an elevated MSI transaction."); 3454 ExitOnFailure(hr, "Failed to rollback an elevated MSI transaction.");
3444 } 3455 }
3445 else 3456 else
3446 { 3457 {
3447 hr = MsiEngineRollbackTransaction(pRollbackBoundary); 3458 hr = MsiEngineRollbackTransaction(pRollbackBoundary, pRestart);
3448 } 3459 }
3449 3460
3450LExit: 3461LExit:
@@ -3454,7 +3465,12 @@ LExit:
3454 3465
3455 if (fRollbackBeginCalled) 3466 if (fRollbackBeginCalled)
3456 { 3467 {
3457 UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); 3468 UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr, *pRestart, &action);
3469
3470 if (action == BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION_RESTART)
3471 {
3472 *pRestart = BOOTSTRAPPER_APPLY_RESTART_INITIATED;
3473 }
3458 } 3474 }
3459 3475
3460 return hr; 3476 return hr;