aboutsummaryrefslogtreecommitdiff
path: root/src/engine/plan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/plan.cpp')
-rw-r--r--src/engine/plan.cpp86
1 files changed, 68 insertions, 18 deletions
diff --git a/src/engine/plan.cpp b/src/engine/plan.cpp
index e2a3437d..22b7033e 100644
--- a/src/engine/plan.cpp
+++ b/src/engine/plan.cpp
@@ -23,9 +23,12 @@ static void UninitializeCacheAction(
23static void ResetPlannedPackageState( 23static void ResetPlannedPackageState(
24 __in BURN_PACKAGE* pPackage 24 __in BURN_PACKAGE* pPackage
25 ); 25 );
26static void ResetPlannedRollbackBoundaryState(
27 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
28 );
26static HRESULT ProcessPackage( 29static HRESULT ProcessPackage(
27 __in BOOL fBundlePerMachine, 30 __in BOOL fBundlePerMachine,
28 __in BURN_PACKAGE* pCompatiblePackageParent, 31 __in_opt BURN_PACKAGE* pCompatiblePackageParent,
29 __in BURN_USER_EXPERIENCE* pUX, 32 __in BURN_USER_EXPERIENCE* pUX,
30 __in BURN_PLAN* pPlan, 33 __in BURN_PLAN* pPlan,
31 __in BURN_PACKAGE* pPackage, 34 __in BURN_PACKAGE* pPackage,
@@ -153,6 +156,7 @@ static HRESULT CalculateExecuteActions(
153 __in BURN_USER_EXPERIENCE* pUserExperience, 156 __in BURN_USER_EXPERIENCE* pUserExperience,
154 __in BURN_PACKAGE* pPackage, 157 __in BURN_PACKAGE* pPackage,
155 __in BURN_VARIABLES* pVariables, 158 __in BURN_VARIABLES* pVariables,
159 __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary,
156 __out_opt BOOL* pfBARequestedCache 160 __out_opt BOOL* pfBARequestedCache
157 ); 161 );
158static BOOL NeedsCache( 162static BOOL NeedsCache(
@@ -263,6 +267,15 @@ extern "C" void PlanReset(
263 ResetPlannedPackageState(&pPackages->rgPackages[i]); 267 ResetPlannedPackageState(&pPackages->rgPackages[i]);
264 } 268 }
265 } 269 }
270
271 // Reset the planned state for each rollback boundary.
272 if (pPackages->rgRollbackBoundaries)
273 {
274 for (DWORD i = 0; i < pPackages->cRollbackBoundaries; ++i)
275 {
276 ResetPlannedRollbackBoundaryState(&pPackages->rgRollbackBoundaries[i]);
277 }
278 }
266} 279}
267 280
268extern "C" void PlanUninitializeExecuteAction( 281extern "C" void PlanUninitializeExecuteAction(
@@ -853,7 +866,7 @@ LExit:
853 866
854static HRESULT ProcessPackage( 867static HRESULT ProcessPackage(
855 __in BOOL fBundlePerMachine, 868 __in BOOL fBundlePerMachine,
856 __in BURN_PACKAGE* pCompatiblePackageParent, 869 __in_opt BURN_PACKAGE* pCompatiblePackageParent,
857 __in BURN_USER_EXPERIENCE* pUX, 870 __in BURN_USER_EXPERIENCE* pUX,
858 __in BURN_PLAN* pPlan, 871 __in BURN_PLAN* pPlan,
859 __in BURN_PACKAGE* pPackage, 872 __in BURN_PACKAGE* pPackage,
@@ -1069,7 +1082,7 @@ extern "C" HRESULT PlanCachePackage(
1069 BOOL fBARequestedCache = FALSE; 1082 BOOL fBARequestedCache = FALSE;
1070 1083
1071 // Calculate the execute actions because we need them to decide whether the package should be cached. 1084 // Calculate the execute actions because we need them to decide whether the package should be cached.
1072 hr = CalculateExecuteActions(pUserExperience, pPackage, pVariables, &fBARequestedCache); 1085 hr = CalculateExecuteActions(pUserExperience, pPackage, pVariables, pPlan->pActiveRollbackBoundary, &fBARequestedCache);
1073 ExitOnFailure(hr, "Failed to calculate execute actions for package: %ls", pPackage->sczId); 1086 ExitOnFailure(hr, "Failed to calculate execute actions for package: %ls", pPackage->sczId);
1074 1087
1075 if (fBARequestedCache || NeedsCache(pPlan, pPackage)) 1088 if (fBARequestedCache || NeedsCache(pPlan, pPackage))
@@ -1105,7 +1118,7 @@ extern "C" HRESULT PlanExecutePackage(
1105 HRESULT hr = S_OK; 1118 HRESULT hr = S_OK;
1106 BOOL fBARequestedCache = FALSE; 1119 BOOL fBARequestedCache = FALSE;
1107 1120
1108 hr = CalculateExecuteActions(pUserExperience, pPackage, pVariables, &fBARequestedCache); 1121 hr = CalculateExecuteActions(pUserExperience, pPackage, pVariables, pPlan->pActiveRollbackBoundary, &fBARequestedCache);
1109 ExitOnFailure(hr, "Failed to calculate plan actions for package: %ls", pPackage->sczId); 1122 ExitOnFailure(hr, "Failed to calculate plan actions for package: %ls", pPackage->sczId);
1110 1123
1111 // Calculate package states based on reference count and plan certain dependency actions prior to planning the package execute action. 1124 // Calculate package states based on reference count and plan certain dependency actions prior to planning the package execute action.
@@ -1631,6 +1644,7 @@ extern "C" HRESULT PlanExecuteCheckpoint(
1631 1644
1632 pAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT; 1645 pAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT;
1633 pAction->checkpoint.dwId = dwCheckpointId; 1646 pAction->checkpoint.dwId = dwCheckpointId;
1647 pAction->checkpoint.pActiveRollbackBoundary = pPlan->pActiveRollbackBoundary;
1634 1648
1635 // rollback checkpoint 1649 // rollback checkpoint
1636 hr = PlanAppendRollbackAction(pPlan, &pAction); 1650 hr = PlanAppendRollbackAction(pPlan, &pAction);
@@ -1638,6 +1652,7 @@ extern "C" HRESULT PlanExecuteCheckpoint(
1638 1652
1639 pAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT; 1653 pAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT;
1640 pAction->checkpoint.dwId = dwCheckpointId; 1654 pAction->checkpoint.dwId = dwCheckpointId;
1655 pAction->checkpoint.pActiveRollbackBoundary = pPlan->pActiveRollbackBoundary;
1641 1656
1642LExit: 1657LExit:
1643 return hr; 1658 return hr;
@@ -1783,6 +1798,9 @@ extern "C" HRESULT PlanRollbackBoundaryBegin(
1783 HRESULT hr = S_OK; 1798 HRESULT hr = S_OK;
1784 BURN_EXECUTE_ACTION* pExecuteAction = NULL; 1799 BURN_EXECUTE_ACTION* pExecuteAction = NULL;
1785 1800
1801 AssertSz(!pPlan->pActiveRollbackBoundary, "PlanRollbackBoundaryBegin called without completing previous RollbackBoundary");
1802 pPlan->pActiveRollbackBoundary = pRollbackBoundary;
1803
1786 // Add begin rollback boundary to execute plan. 1804 // Add begin rollback boundary to execute plan.
1787 hr = PlanAppendExecuteAction(pPlan, &pExecuteAction); 1805 hr = PlanAppendExecuteAction(pPlan, &pExecuteAction);
1788 ExitOnFailure(hr, "Failed to append rollback boundary begin action."); 1806 ExitOnFailure(hr, "Failed to append rollback boundary begin action.");
@@ -1797,6 +1815,19 @@ extern "C" HRESULT PlanRollbackBoundaryBegin(
1797 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_ROLLBACK_BOUNDARY; 1815 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_ROLLBACK_BOUNDARY;
1798 pExecuteAction->rollbackBoundary.pRollbackBoundary = pRollbackBoundary; 1816 pExecuteAction->rollbackBoundary.pRollbackBoundary = pRollbackBoundary;
1799 1817
1818 // Add begin MSI transaction to execute plan.
1819 if (pRollbackBoundary->fTransaction)
1820 {
1821 hr = PlanExecuteCheckpoint(pPlan);
1822 ExitOnFailure(hr, "Failed to append checkpoint before MSI transaction begin action.");
1823
1824 hr = PlanAppendExecuteAction(pPlan, &pExecuteAction);
1825 ExitOnFailure(hr, "Failed to append MSI transaction begin action.");
1826
1827 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_BEGIN_MSI_TRANSACTION;
1828 pExecuteAction->msiTransaction.pRollbackBoundary = pRollbackBoundary;
1829 }
1830
1800LExit: 1831LExit:
1801 return hr; 1832 return hr;
1802} 1833}
@@ -1807,22 +1838,24 @@ extern "C" HRESULT PlanRollbackBoundaryComplete(
1807{ 1838{
1808 HRESULT hr = S_OK; 1839 HRESULT hr = S_OK;
1809 BURN_EXECUTE_ACTION* pExecuteAction = NULL; 1840 BURN_EXECUTE_ACTION* pExecuteAction = NULL;
1810 DWORD dwCheckpointId = 0; 1841 BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = pPlan->pActiveRollbackBoundary;
1811 1842
1812 // Add checkpoints. 1843 AssertSz(pRollbackBoundary, "PlanRollbackBoundaryComplete called without an active RollbackBoundary");
1813 dwCheckpointId = GetNextCheckpointId(pPlan);
1814 1844
1815 hr = PlanAppendExecuteAction(pPlan, &pExecuteAction); 1845 if (pRollbackBoundary && pRollbackBoundary->fTransaction)
1816 ExitOnFailure(hr, "Failed to append execute action."); 1846 {
1847 // Add commit MSI transaction to execute plan.
1848 hr = PlanAppendExecuteAction(pPlan, &pExecuteAction);
1849 ExitOnFailure(hr, "Failed to append MSI transaction commit action.");
1817 1850
1818 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT; 1851 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION;
1819 pExecuteAction->checkpoint.dwId = dwCheckpointId; 1852 pExecuteAction->msiTransaction.pRollbackBoundary = pRollbackBoundary;
1853 }
1820 1854
1821 hr = PlanAppendRollbackAction(pPlan, &pExecuteAction); 1855 pPlan->pActiveRollbackBoundary = NULL;
1822 ExitOnFailure(hr, "Failed to append rollback action.");
1823 1856
1824 pExecuteAction->type = BURN_EXECUTE_ACTION_TYPE_CHECKPOINT; 1857 // Add checkpoints.
1825 pExecuteAction->checkpoint.dwId = dwCheckpointId; 1858 hr = PlanExecuteCheckpoint(pPlan);
1826 1859
1827LExit: 1860LExit:
1828 return hr; 1861 return hr;
@@ -1936,6 +1969,13 @@ static void ResetPlannedPackageState(
1936 } 1969 }
1937} 1970}
1938 1971
1972static void ResetPlannedRollbackBoundaryState(
1973 __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary
1974 )
1975{
1976 pRollbackBoundary->fActiveTransaction = FALSE;
1977}
1978
1939static HRESULT GetActionDefaultRequestState( 1979static HRESULT GetActionDefaultRequestState(
1940 __in BOOTSTRAPPER_ACTION action, 1980 __in BOOTSTRAPPER_ACTION action,
1941 __in BOOL fPermanent, 1981 __in BOOL fPermanent,
@@ -2848,10 +2888,12 @@ static HRESULT CalculateExecuteActions(
2848 __in BURN_USER_EXPERIENCE* pUserExperience, 2888 __in BURN_USER_EXPERIENCE* pUserExperience,
2849 __in BURN_PACKAGE* pPackage, 2889 __in BURN_PACKAGE* pPackage,
2850 __in BURN_VARIABLES* pVariables, 2890 __in BURN_VARIABLES* pVariables,
2891 __in_opt BURN_ROLLBACK_BOUNDARY* pActiveRollbackBoundary,
2851 __out_opt BOOL* pfBARequestedCache 2892 __out_opt BOOL* pfBARequestedCache
2852 ) 2893 )
2853{ 2894{
2854 HRESULT hr = S_OK; 2895 HRESULT hr = S_OK;
2896 BOOL fInsideMsiTransaction = pActiveRollbackBoundary && pActiveRollbackBoundary->fTransaction;
2855 2897
2856 // Calculate execute actions. 2898 // Calculate execute actions.
2857 switch (pPackage->type) 2899 switch (pPackage->type)
@@ -2861,11 +2903,11 @@ static HRESULT CalculateExecuteActions(
2861 break; 2903 break;
2862 2904
2863 case BURN_PACKAGE_TYPE_MSI: 2905 case BURN_PACKAGE_TYPE_MSI:
2864 hr = MsiEnginePlanCalculatePackage(pPackage, pVariables, pUserExperience, pfBARequestedCache); 2906 hr = MsiEnginePlanCalculatePackage(pPackage, pVariables, pUserExperience, fInsideMsiTransaction, pfBARequestedCache);
2865 break; 2907 break;
2866 2908
2867 case BURN_PACKAGE_TYPE_MSP: 2909 case BURN_PACKAGE_TYPE_MSP:
2868 hr = MspEnginePlanCalculatePackage(pPackage, pUserExperience, pfBARequestedCache); 2910 hr = MspEnginePlanCalculatePackage(pPackage, pUserExperience, fInsideMsiTransaction, pfBARequestedCache);
2869 break; 2911 break;
2870 2912
2871 case BURN_PACKAGE_TYPE_MSU: 2913 case BURN_PACKAGE_TYPE_MSU:
@@ -3065,7 +3107,7 @@ static void ExecuteActionLog(
3065 switch (pAction->type) 3107 switch (pAction->type)
3066 { 3108 {
3067 case BURN_EXECUTE_ACTION_TYPE_CHECKPOINT: 3109 case BURN_EXECUTE_ACTION_TYPE_CHECKPOINT:
3068 LogStringLine(REPORT_STANDARD, "%ls action[%u]: CHECKPOINT id: %u", wzBase, iAction, pAction->checkpoint.dwId); 3110 LogStringLine(REPORT_STANDARD, "%ls action[%u]: CHECKPOINT id: %u, msi transaction id: %ls", wzBase, iAction, pAction->checkpoint.dwId, pAction->checkpoint.pActiveRollbackBoundary && pAction->checkpoint.pActiveRollbackBoundary->fTransaction ? pAction->checkpoint.pActiveRollbackBoundary->sczId : L"(none)");
3069 break; 3111 break;
3070 3112
3071 case BURN_EXECUTE_ACTION_TYPE_PACKAGE_PROVIDER: 3113 case BURN_EXECUTE_ACTION_TYPE_PACKAGE_PROVIDER:
@@ -3120,6 +3162,14 @@ static void ExecuteActionLog(
3120 LogStringLine(REPORT_STANDARD, "%ls action[%u]: COMPATIBLE_PACKAGE reference id: %ls, installed ProductCode: %ls", wzBase, iAction, pAction->compatiblePackage.pReferencePackage->sczId, pAction->compatiblePackage.sczInstalledProductCode); 3162 LogStringLine(REPORT_STANDARD, "%ls action[%u]: COMPATIBLE_PACKAGE reference id: %ls, installed ProductCode: %ls", wzBase, iAction, pAction->compatiblePackage.pReferencePackage->sczId, pAction->compatiblePackage.sczInstalledProductCode);
3121 break; 3163 break;
3122 3164
3165 case BURN_EXECUTE_ACTION_TYPE_BEGIN_MSI_TRANSACTION:
3166 LogStringLine(REPORT_STANDARD, "%ls action[%u]: BEGIN_MSI_TRANSACTION id: %ls", wzBase, iAction, pAction->msiTransaction.pRollbackBoundary->sczId);
3167 break;
3168
3169 case BURN_EXECUTE_ACTION_TYPE_COMMIT_MSI_TRANSACTION:
3170 LogStringLine(REPORT_STANDARD, "%ls action[%u]: COMMIT_MSI_TRANSACTION id: %ls", wzBase, iAction, pAction->msiTransaction.pRollbackBoundary->sczId);
3171 break;
3172
3123 default: 3173 default:
3124 AssertSz(FALSE, "Unknown execute action type."); 3174 AssertSz(FALSE, "Unknown execute action type.");
3125 break; 3175 break;