-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BA Plan & log transaction #54
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -695,6 +695,7 @@ extern "C" HRESULT ApplyExecute( | |
break; | ||
} | ||
|
||
// The action failed, roll back to previous rollback boundary. | ||
if (pCheckpoint) | ||
{ | ||
// If inside a MSI transaction, roll it back. | ||
|
@@ -717,6 +718,7 @@ extern "C" HRESULT ApplyExecute( | |
} | ||
|
||
// Move forward to next rollback boundary. | ||
hr = S_OK; | ||
rseanhall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fSeekNextRollbackBoundary = TRUE; | ||
} | ||
} | ||
|
@@ -2787,6 +2789,8 @@ static HRESULT ExecuteMsiBeginTransaction( | |
{ | ||
HRESULT hr = S_OK; | ||
BOOL fBeginCalled = FALSE; | ||
MSIHANDLE hMsiTrns = NULL; | ||
HANDLE hMsiTrnsEvent = NULL; | ||
Comment on lines
+2792
to
+2793
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
|
||
if (pRollbackBoundary->fActiveTransaction) | ||
{ | ||
|
@@ -2797,14 +2801,16 @@ static HRESULT ExecuteMsiBeginTransaction( | |
hr = UserExperienceOnBeginMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); | ||
ExitOnRootFailure(hr, "BA aborted execute begin MSI transaction."); | ||
|
||
LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_BEGIN, pRollbackBoundary->sczId); | ||
|
||
Comment on lines
+2804
to
+2805
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
if (pEngineState->plan.fPerMachine) | ||
{ | ||
hr = ElevationMsiBeginTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to begin an elevated MSI transaction."); | ||
} | ||
else | ||
{ | ||
hr = MsiEngineBeginTransaction(pRollbackBoundary); | ||
hr = MsiEngineBeginTransaction(pRollbackBoundary->sczId, &hMsiTrns, &hMsiTrnsEvent, pRollbackBoundary->sczLogPath); | ||
Comment on lines
-2807
to
+2813
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
} | ||
|
||
if (SUCCEEDED(hr)) | ||
|
@@ -2820,6 +2826,9 @@ static HRESULT ExecuteMsiBeginTransaction( | |
UserExperienceOnBeginMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); | ||
} | ||
|
||
ReleaseHandle(hMsiTrnsEvent); | ||
ReleaseMsi(hMsiTrns); | ||
|
||
return hr; | ||
} | ||
|
||
|
@@ -2830,25 +2839,27 @@ static HRESULT ExecuteMsiCommitTransaction( | |
) | ||
{ | ||
HRESULT hr = S_OK; | ||
BOOL fCommitBeginCalled = FALSE; | ||
BOOL fCommitCalled = FALSE; | ||
Comment on lines
-2833
to
+2842
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
|
||
if (!pRollbackBoundary->fActiveTransaction) | ||
{ | ||
ExitFunction1(hr = E_INVALIDSTATE); | ||
} | ||
|
||
fCommitBeginCalled = TRUE; | ||
fCommitCalled = TRUE; | ||
hr = UserExperienceOnCommitMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); | ||
ExitOnRootFailure(hr, "BA aborted execute commit MSI transaction."); | ||
|
||
LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_COMMIT, pRollbackBoundary->sczId); | ||
|
||
if (pEngineState->plan.fPerMachine) | ||
{ | ||
hr = ElevationMsiCommitTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to commit an elevated MSI transaction."); | ||
} | ||
else | ||
{ | ||
hr = MsiEngineCommitTransaction(pRollbackBoundary); | ||
hr = MsiEngineCommitTransaction(NULL, NULL, pRollbackBoundary->sczLogPath); | ||
} | ||
|
||
if (SUCCEEDED(hr)) | ||
|
@@ -2859,7 +2870,7 @@ static HRESULT ExecuteMsiCommitTransaction( | |
} | ||
|
||
LExit: | ||
if (fCommitBeginCalled) | ||
if (fCommitCalled) | ||
{ | ||
UserExperienceOnCommitMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); | ||
} | ||
|
@@ -2874,32 +2885,34 @@ static HRESULT ExecuteMsiRollbackTransaction( | |
) | ||
{ | ||
HRESULT hr = S_OK; | ||
BOOL fRollbackBeginCalled = FALSE; | ||
BOOL fRlbkCalled = FALSE; | ||
Comment on lines
-2877
to
+2888
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
|
||
if (!pRollbackBoundary->fActiveTransaction) | ||
{ | ||
ExitFunction(); | ||
} | ||
|
||
fRollbackBeginCalled = TRUE; | ||
fRlbkCalled = TRUE; | ||
UserExperienceOnRollbackMsiTransactionBegin(&pEngineState->userExperience, pRollbackBoundary->sczId); | ||
|
||
LogId(REPORT_WARNING, MSG_MSI_TRANSACTION_ROLLBACK, pRollbackBoundary->sczId); | ||
|
||
if (pEngineState->plan.fPerMachine) | ||
{ | ||
hr = ElevationMsiRollbackTransaction(pEngineState->companionConnection.hPipe, pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to rollback an elevated MSI transaction."); | ||
} | ||
else | ||
{ | ||
hr = MsiEngineRollbackTransaction(pRollbackBoundary); | ||
hr = MsiEngineRollbackTransaction(NULL, NULL, pRollbackBoundary->sczLogPath); | ||
} | ||
|
||
LExit: | ||
pRollbackBoundary->fActiveTransaction = FALSE; | ||
|
||
ResetTransactionRegistrationState(pEngineState, FALSE); | ||
|
||
if (fRollbackBeginCalled) | ||
if (fRlbkCalled) | ||
{ | ||
UserExperienceOnRollbackMsiTransactionComplete(&pEngineState->userExperience, pRollbackBoundary->sczId, hr); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,17 +285,14 @@ static HRESULT OnLaunchApprovedExe( | |
__in DWORD cbData | ||
); | ||
static HRESULT OnMsiBeginTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
); | ||
static HRESULT OnMsiCommitTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
); | ||
static HRESULT OnMsiRollbackTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
); | ||
|
@@ -846,9 +843,6 @@ extern "C" HRESULT ElevationMsiCommitTransaction( | |
DWORD dwResult = ERROR_SUCCESS; | ||
|
||
// serialize message data | ||
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczId); | ||
ExitOnFailure(hr, "Failed to write transaction name to message buffer."); | ||
|
||
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczLogPath); | ||
ExitOnFailure(hr, "Failed to write transaction log path to message buffer."); | ||
|
||
|
@@ -858,6 +852,8 @@ extern "C" HRESULT ElevationMsiCommitTransaction( | |
hr = static_cast<HRESULT>(dwResult); | ||
|
||
LExit: | ||
ReleaseBuffer(pbData); | ||
|
||
Comment on lines
+855
to
+856
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this. But why are you insisting on all the other changes here? |
||
return hr; | ||
} | ||
|
||
|
@@ -872,9 +868,6 @@ extern "C" HRESULT ElevationMsiRollbackTransaction( | |
DWORD dwResult = ERROR_SUCCESS; | ||
|
||
// serialize message data | ||
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczId); | ||
ExitOnFailure(hr, "Failed to write transaction name to message buffer."); | ||
|
||
hr = BuffWriteString(&pbData, &cbData, pRollbackBoundary->sczLogPath); | ||
ExitOnFailure(hr, "Failed to write transaction log path to message buffer."); | ||
|
||
|
@@ -884,6 +877,8 @@ extern "C" HRESULT ElevationMsiRollbackTransaction( | |
hr = static_cast<HRESULT>(dwResult); | ||
|
||
LExit: | ||
ReleaseBuffer(pbData); | ||
|
||
return hr; | ||
} | ||
|
||
|
@@ -1758,15 +1753,15 @@ static HRESULT ProcessElevatedChildMessage( | |
switch (pMsg->dwMessage) | ||
{ | ||
case BURN_ELEVATION_MESSAGE_TYPE_BEGIN_MSI_TRANSACTION: | ||
hrResult = OnMsiBeginTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
hrResult = OnMsiBeginTransaction((BYTE*)pMsg->pvData, pMsg->cbData); | ||
break; | ||
|
||
case BURN_ELEVATION_MESSAGE_TYPE_COMMIT_MSI_TRANSACTION: | ||
hrResult = OnMsiCommitTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
hrResult = OnMsiCommitTransaction((BYTE*)pMsg->pvData, pMsg->cbData); | ||
break; | ||
|
||
case BURN_ELEVATION_MESSAGE_TYPE_ROLLBACK_MSI_TRANSACTION: | ||
hrResult = OnMsiRollbackTransaction(pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData); | ||
hrResult = OnMsiRollbackTransaction((BYTE*)pMsg->pvData, pMsg->cbData); | ||
break; | ||
|
||
case BURN_ELEVATION_MESSAGE_TYPE_APPLY_INITIALIZE: | ||
|
@@ -3049,116 +3044,77 @@ static HRESULT OnLaunchApprovedExe( | |
} | ||
|
||
static HRESULT OnMsiBeginTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
) | ||
{ | ||
HRESULT hr = S_OK; | ||
SIZE_T iData = 0; | ||
LPWSTR sczId = NULL; | ||
LPWSTR szName = NULL; | ||
LPWSTR sczLogPath = NULL; | ||
BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
MSIHANDLE hMsiTrns = NULL; | ||
HANDLE hMsiTrnsEvent = NULL; | ||
|
||
// Deserialize message data. | ||
hr = BuffReadString(pbData, cbData, &iData, &sczId); | ||
ExitOnFailure(hr, "Failed to read rollback boundary id."); | ||
hr = BuffReadString(pbData, cbData, &iData, &szName); | ||
ExitOnFailure(hr, "Failed to read transaction name."); | ||
|
||
hr = BuffReadString(pbData, cbData, &iData, &sczLogPath); | ||
ExitOnFailure(hr, "Failed to read transaction log path."); | ||
|
||
PackageFindRollbackBoundaryById(pPackages, sczId, &pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to find rollback boundary: %ls", sczId); | ||
|
||
pRollbackBoundary->sczLogPath = sczLogPath; | ||
|
||
hr = MsiEngineBeginTransaction(pRollbackBoundary); | ||
hr = MsiEngineBeginTransaction(szName, &hMsiTrns, &hMsiTrnsEvent, sczLogPath); | ||
ExitOnFailure(hr, "Failed beginning an MSI transaction"); | ||
Comment on lines
-3070
to
+3066
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you insisting on these changes? |
||
|
||
LExit: | ||
ReleaseStr(sczId); | ||
ReleaseStr(szName); | ||
ReleaseStr(sczLogPath); | ||
|
||
if (pRollbackBoundary) | ||
{ | ||
pRollbackBoundary->sczLogPath = NULL; | ||
} | ||
ReleaseHandle(hMsiTrnsEvent); | ||
ReleaseMsi(hMsiTrns); | ||
|
||
return hr; | ||
} | ||
|
||
static HRESULT OnMsiCommitTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
) | ||
{ | ||
HRESULT hr = S_OK; | ||
SIZE_T iData = 0; | ||
LPWSTR sczId = NULL; | ||
LPWSTR sczLogPath = NULL; | ||
BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
|
||
// Deserialize message data. | ||
hr = BuffReadString(pbData, cbData, &iData, &sczId); | ||
ExitOnFailure(hr, "Failed to read rollback boundary id."); | ||
|
||
hr = BuffReadString(pbData, cbData, &iData, &sczLogPath); | ||
ExitOnFailure(hr, "Failed to read transaction log path."); | ||
|
||
PackageFindRollbackBoundaryById(pPackages, sczId, &pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to find rollback boundary: %ls", sczId); | ||
|
||
pRollbackBoundary->sczLogPath = sczLogPath; | ||
|
||
hr = MsiEngineCommitTransaction(pRollbackBoundary); | ||
hr = MsiEngineCommitTransaction(NULL, NULL, sczLogPath); | ||
ExitOnFailure(hr, "Failed committing an MSI transaction"); | ||
|
||
LExit: | ||
ReleaseStr(sczId); | ||
ReleaseStr(sczLogPath); | ||
|
||
if (pRollbackBoundary) | ||
{ | ||
pRollbackBoundary->sczLogPath = NULL; | ||
} | ||
|
||
return hr; | ||
} | ||
|
||
static HRESULT OnMsiRollbackTransaction( | ||
__in BURN_PACKAGES* pPackages, | ||
__in BYTE* pbData, | ||
__in DWORD cbData | ||
) | ||
{ | ||
HRESULT hr = S_OK; | ||
SIZE_T iData = 0; | ||
LPWSTR sczId = NULL; | ||
LPWSTR sczLogPath = NULL; | ||
BURN_ROLLBACK_BOUNDARY* pRollbackBoundary = NULL; | ||
|
||
// Deserialize message data. | ||
hr = BuffReadString(pbData, cbData, &iData, &sczId); | ||
ExitOnFailure(hr, "Failed to read rollback boundary id."); | ||
|
||
hr = BuffReadString(pbData, cbData, &iData, &sczLogPath); | ||
ExitOnFailure(hr, "Failed to read transaction log path."); | ||
|
||
PackageFindRollbackBoundaryById(pPackages, sczId, &pRollbackBoundary); | ||
ExitOnFailure(hr, "Failed to find rollback boundary: %ls", sczId); | ||
|
||
pRollbackBoundary->sczLogPath = sczLogPath; | ||
|
||
hr = MsiEngineRollbackTransaction(pRollbackBoundary); | ||
hr = MsiEngineRollbackTransaction(NULL, NULL, sczLogPath); | ||
ExitOnFailure(hr, "Failed rolling back an MSI transaction"); | ||
|
||
LExit: | ||
ReleaseStr(sczId); | ||
ReleaseStr(sczLogPath); | ||
|
||
if (pRollbackBoundary) | ||
{ | ||
pRollbackBoundary->sczLogPath = NULL; | ||
} | ||
|
||
return hr; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. wixtoolset/balutil#28 (comment)