diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-02 16:56:57 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-02-04 22:16:10 -0600 |
commit | bb7d4bdc09d0b52a65b8cf3b5ae629f385fc8011 (patch) | |
tree | 6d144200ff008c8e8f1f74a51475c54b95f04912 /src/engine/core.cpp | |
parent | cc5fe7c79aad14819df1b4cb134884b80a945141 (diff) | |
download | wix-bb7d4bdc09d0b52a65b8cf3b5ae629f385fc8011.tar.gz wix-bb7d4bdc09d0b52a65b8cf3b5ae629f385fc8011.tar.bz2 wix-bb7d4bdc09d0b52a65b8cf3b5ae629f385fc8011.zip |
Clean up synchronization between the engine and the BA.
Diffstat (limited to 'src/engine/core.cpp')
-rw-r--r-- | src/engine/core.cpp | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/engine/core.cpp b/src/engine/core.cpp index ae09ea65..a644d377 100644 --- a/src/engine/core.cpp +++ b/src/engine/core.cpp | |||
@@ -236,16 +236,12 @@ extern "C" HRESULT CoreDetect( | |||
236 | ) | 236 | ) |
237 | { | 237 | { |
238 | HRESULT hr = S_OK; | 238 | HRESULT hr = S_OK; |
239 | BOOL fActivated = FALSE; | ||
240 | BOOL fDetectBegan = FALSE; | 239 | BOOL fDetectBegan = FALSE; |
241 | BURN_PACKAGE* pPackage = NULL; | 240 | BURN_PACKAGE* pPackage = NULL; |
242 | HRESULT hrFirstPackageFailure = S_OK; | 241 | HRESULT hrFirstPackageFailure = S_OK; |
243 | 242 | ||
244 | LogId(REPORT_STANDARD, MSG_DETECT_BEGIN, pEngineState->packages.cPackages); | 243 | LogId(REPORT_STANDARD, MSG_DETECT_BEGIN, pEngineState->packages.cPackages); |
245 | 244 | ||
246 | hr = UserExperienceActivateEngine(&pEngineState->userExperience, &fActivated); | ||
247 | ExitOnFailure(hr, "Engine cannot start detect because it is busy with another action."); | ||
248 | |||
249 | // Detect if bundle installed state has changed since start up. This | 245 | // Detect if bundle installed state has changed since start up. This |
250 | // only happens if Apply() changed the state of bundle (installed or | 246 | // only happens if Apply() changed the state of bundle (installed or |
251 | // uninstalled). In that case, Detect() can be used here to reset | 247 | // uninstalled). In that case, Detect() can be used here to reset |
@@ -369,11 +365,6 @@ LExit: | |||
369 | hr = hrFirstPackageFailure; | 365 | hr = hrFirstPackageFailure; |
370 | } | 366 | } |
371 | 367 | ||
372 | if (fActivated) | ||
373 | { | ||
374 | UserExperienceDeactivateEngine(&pEngineState->userExperience); | ||
375 | } | ||
376 | |||
377 | if (fDetectBegan) | 368 | if (fDetectBegan) |
378 | { | 369 | { |
379 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr); | 370 | UserExperienceOnDetectComplete(&pEngineState->userExperience, hr); |
@@ -392,7 +383,6 @@ extern "C" HRESULT CorePlan( | |||
392 | ) | 383 | ) |
393 | { | 384 | { |
394 | HRESULT hr = S_OK; | 385 | HRESULT hr = S_OK; |
395 | BOOL fActivated = FALSE; | ||
396 | BOOL fPlanBegan = FALSE; | 386 | BOOL fPlanBegan = FALSE; |
397 | LPWSTR sczLayoutDirectory = NULL; | 387 | LPWSTR sczLayoutDirectory = NULL; |
398 | HANDLE hSyncpointEvent = NULL; | 388 | HANDLE hSyncpointEvent = NULL; |
@@ -401,9 +391,6 @@ extern "C" HRESULT CorePlan( | |||
401 | 391 | ||
402 | LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action)); | 392 | LogId(REPORT_STANDARD, MSG_PLAN_BEGIN, pEngineState->packages.cPackages, LoggingBurnActionToString(action)); |
403 | 393 | ||
404 | hr = UserExperienceActivateEngine(&pEngineState->userExperience, &fActivated); | ||
405 | ExitOnFailure(hr, "Engine cannot start plan because it is busy with another action."); | ||
406 | |||
407 | fPlanBegan = TRUE; | 394 | fPlanBegan = TRUE; |
408 | hr = UserExperienceOnPlanBegin(&pEngineState->userExperience, pEngineState->packages.cPackages); | 395 | hr = UserExperienceOnPlanBegin(&pEngineState->userExperience, pEngineState->packages.cPackages); |
409 | ExitOnRootFailure(hr, "BA aborted plan begin."); | 396 | ExitOnRootFailure(hr, "BA aborted plan begin."); |
@@ -496,11 +483,6 @@ extern "C" HRESULT CorePlan( | |||
496 | PlanDump(&pEngineState->plan); | 483 | PlanDump(&pEngineState->plan); |
497 | 484 | ||
498 | LExit: | 485 | LExit: |
499 | if (fActivated) | ||
500 | { | ||
501 | UserExperienceDeactivateEngine(&pEngineState->userExperience); | ||
502 | } | ||
503 | |||
504 | if (fPlanBegan) | 486 | if (fPlanBegan) |
505 | { | 487 | { |
506 | UserExperienceOnPlanComplete(&pEngineState->userExperience, hr); | 488 | UserExperienceOnPlanComplete(&pEngineState->userExperience, hr); |
@@ -551,10 +533,10 @@ extern "C" HRESULT CoreApply( | |||
551 | ) | 533 | ) |
552 | { | 534 | { |
553 | HRESULT hr = S_OK; | 535 | HRESULT hr = S_OK; |
554 | BOOL fActivated = FALSE; | ||
555 | HANDLE hLock = NULL; | 536 | HANDLE hLock = NULL; |
556 | DWORD cOverallProgressTicks = 0; | 537 | DWORD cOverallProgressTicks = 0; |
557 | HANDLE hCacheThread = NULL; | 538 | HANDLE hCacheThread = NULL; |
539 | BOOL fApplyInitialize = FALSE; | ||
558 | BOOL fElevated = FALSE; | 540 | BOOL fElevated = FALSE; |
559 | BOOL fRegistered = FALSE; | 541 | BOOL fRegistered = FALSE; |
560 | BOOL fKeepRegistration = pEngineState->plan.fKeepRegistrationDefault; | 542 | BOOL fKeepRegistration = pEngineState->plan.fKeepRegistrationDefault; |
@@ -567,9 +549,6 @@ extern "C" HRESULT CoreApply( | |||
567 | 549 | ||
568 | LogId(REPORT_STANDARD, MSG_APPLY_BEGIN); | 550 | LogId(REPORT_STANDARD, MSG_APPLY_BEGIN); |
569 | 551 | ||
570 | hr = UserExperienceActivateEngine(&pEngineState->userExperience, &fActivated); | ||
571 | ExitOnFailure(hr, "Engine cannot start apply because it is busy with another action."); | ||
572 | |||
573 | // Ensure any previous attempts to execute are reset. | 552 | // Ensure any previous attempts to execute are reset. |
574 | ApplyReset(&pEngineState->userExperience, &pEngineState->packages); | 553 | ApplyReset(&pEngineState->userExperience, &pEngineState->packages); |
575 | 554 | ||
@@ -599,6 +578,7 @@ extern "C" HRESULT CoreApply( | |||
599 | ExitOnFailure(hr, "Another per-user setup is already executing."); | 578 | ExitOnFailure(hr, "Another per-user setup is already executing."); |
600 | 579 | ||
601 | // Initialize only after getting a lock. | 580 | // Initialize only after getting a lock. |
581 | fApplyInitialize = TRUE; | ||
602 | ApplyInitialize(); | 582 | ApplyInitialize(); |
603 | 583 | ||
604 | pEngineState->userExperience.hwndApply = hwndParent; | 584 | pEngineState->userExperience.hwndApply = hwndParent; |
@@ -627,7 +607,7 @@ extern "C" HRESULT CoreApply( | |||
627 | ExitOnFailure(hr, "Failed to elevate."); | 607 | ExitOnFailure(hr, "Failed to elevate."); |
628 | 608 | ||
629 | hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, pEngineState->plan.action, pEngineState->automaticUpdates, !pEngineState->fDisableSystemRestore); | 609 | hr = ElevationApplyInitialize(pEngineState->companionConnection.hPipe, &pEngineState->userExperience, &pEngineState->variables, pEngineState->plan.action, pEngineState->automaticUpdates, !pEngineState->fDisableSystemRestore); |
630 | ExitOnFailure(hr, "Another per-machine setup is already executing."); | 610 | ExitOnFailure(hr, "Failed to initialize apply in elevated process."); |
631 | 611 | ||
632 | fElevated = TRUE; | 612 | fElevated = TRUE; |
633 | } | 613 | } |
@@ -704,7 +684,10 @@ LExit: | |||
704 | 684 | ||
705 | pEngineState->userExperience.hwndApply = NULL; | 685 | pEngineState->userExperience.hwndApply = NULL; |
706 | 686 | ||
707 | ApplyUninitialize(); | 687 | if (fApplyInitialize) |
688 | { | ||
689 | ApplyUninitialize(); | ||
690 | } | ||
708 | 691 | ||
709 | if (hLock) | 692 | if (hLock) |
710 | { | 693 | { |
@@ -712,11 +695,6 @@ LExit: | |||
712 | ::CloseHandle(hLock); | 695 | ::CloseHandle(hLock); |
713 | } | 696 | } |
714 | 697 | ||
715 | if (fActivated) | ||
716 | { | ||
717 | UserExperienceDeactivateEngine(&pEngineState->userExperience); | ||
718 | } | ||
719 | |||
720 | ReleaseHandle(hCacheThread); | 698 | ReleaseHandle(hCacheThread); |
721 | 699 | ||
722 | UserExperienceOnApplyComplete(&pEngineState->userExperience, hr, restart, &applyCompleteAction); | 700 | UserExperienceOnApplyComplete(&pEngineState->userExperience, hr, restart, &applyCompleteAction); |
@@ -736,14 +714,10 @@ extern "C" HRESULT CoreLaunchApprovedExe( | |||
736 | ) | 714 | ) |
737 | { | 715 | { |
738 | HRESULT hr = S_OK; | 716 | HRESULT hr = S_OK; |
739 | BOOL fActivated = FALSE; | ||
740 | DWORD dwProcessId = 0; | 717 | DWORD dwProcessId = 0; |
741 | 718 | ||
742 | LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_BEGIN, pLaunchApprovedExe->sczId); | 719 | LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_BEGIN, pLaunchApprovedExe->sczId); |
743 | 720 | ||
744 | hr = UserExperienceActivateEngine(&pEngineState->userExperience, &fActivated); | ||
745 | ExitOnFailure(hr, "Engine cannot start LaunchApprovedExe because it is busy with another action."); | ||
746 | |||
747 | hr = UserExperienceOnLaunchApprovedExeBegin(&pEngineState->userExperience); | 721 | hr = UserExperienceOnLaunchApprovedExeBegin(&pEngineState->userExperience); |
748 | ExitOnRootFailure(hr, "BA aborted LaunchApprovedExe begin."); | 722 | ExitOnRootFailure(hr, "BA aborted LaunchApprovedExe begin."); |
749 | 723 | ||
@@ -755,11 +729,6 @@ extern "C" HRESULT CoreLaunchApprovedExe( | |||
755 | hr = ElevationLaunchApprovedExe(pEngineState->companionConnection.hPipe, pLaunchApprovedExe, &dwProcessId); | 729 | hr = ElevationLaunchApprovedExe(pEngineState->companionConnection.hPipe, pLaunchApprovedExe, &dwProcessId); |
756 | 730 | ||
757 | LExit: | 731 | LExit: |
758 | if (fActivated) | ||
759 | { | ||
760 | UserExperienceDeactivateEngine(&pEngineState->userExperience); | ||
761 | } | ||
762 | |||
763 | UserExperienceOnLaunchApprovedExeComplete(&pEngineState->userExperience, hr, dwProcessId); | 732 | UserExperienceOnLaunchApprovedExeComplete(&pEngineState->userExperience, hr, dwProcessId); |
764 | 733 | ||
765 | LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_COMPLETE, hr, dwProcessId); | 734 | LogId(REPORT_STANDARD, MSG_LAUNCH_APPROVED_EXE_COMPLETE, hr, dwProcessId); |
@@ -782,7 +751,7 @@ extern "C" HRESULT CoreQuit( | |||
782 | hr = CoreSaveEngineState(pEngineState); | 751 | hr = CoreSaveEngineState(pEngineState); |
783 | if (FAILED(hr)) | 752 | if (FAILED(hr)) |
784 | { | 753 | { |
785 | LogErrorId(hr, MSG_STATE_NOT_SAVED, NULL, NULL, NULL); | 754 | LogErrorId(hr, MSG_STATE_NOT_SAVED); |
786 | hr = S_OK; | 755 | hr = S_OK; |
787 | } | 756 | } |
788 | } | 757 | } |