From b7582318f6cb6e166f5ca22128caea2a97551a1f Mon Sep 17 00:00:00 2001 From: Nir Bar Date: Wed, 17 Mar 2021 14:45:03 -0500 Subject: Use wiutil to start/end msi transactions Release MSI transaction handles immediately contributes to #5386 --- src/engine/msiengine.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/engine/msiengine.cpp') diff --git a/src/engine/msiengine.cpp b/src/engine/msiengine.cpp index f0aa784e..6c5b760b 100644 --- a/src/engine/msiengine.cpp +++ b/src/engine/msiengine.cpp @@ -1016,40 +1016,41 @@ LExit: } extern "C" HRESULT MsiEngineBeginTransaction( - __in LPCWSTR wzName + __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary ) { HRESULT hr = S_OK; - UINT uResult = ERROR_SUCCESS; MSIHANDLE hTransactionHandle = NULL; HANDLE hChangeOfOwnerEvent = NULL; - LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_BEGIN, wzName); + LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_BEGIN, pRollbackBoundary->sczId); - uResult = ::MsiBeginTransaction(wzName, 0, &hTransactionHandle, &hChangeOfOwnerEvent); + hr = WiuBeginTransaction(pRollbackBoundary->sczId, 0, &hTransactionHandle, &hChangeOfOwnerEvent, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath); - if (ERROR_ROLLBACK_DISABLED == uResult) + if (HRESULT_FROM_WIN32(ERROR_ROLLBACK_DISABLED) == hr) { LogId(REPORT_ERROR, MSG_MSI_TRANSACTIONS_DISABLED); } - ExitOnWin32Error(uResult, hr, "Failed to begin an MSI transaction"); + ExitOnFailure(hr, "Failed to begin an MSI transaction"); LExit: + ReleaseMsi(hTransactionHandle); + ReleaseHandle(hChangeOfOwnerEvent); + return hr; } extern "C" HRESULT MsiEngineCommitTransaction( - __in LPCWSTR wzName + __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary ) { HRESULT hr = S_OK; - UINT uResult = ERROR_SUCCESS; - LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_COMMIT, wzName); + LogId(REPORT_STANDARD, MSG_MSI_TRANSACTION_COMMIT, pRollbackBoundary->sczId); - uResult = ::MsiEndTransaction(MSITRANSACTIONSTATE_COMMIT); - ExitOnWin32Error(uResult, hr, "Failed to commit the MSI transaction"); + hr = WiuEndTransaction(MSITRANSACTIONSTATE_COMMIT, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath); + ExitOnFailure(hr, "Failed to commit the MSI transaction"); LExit: @@ -1057,16 +1058,15 @@ LExit: } extern "C" HRESULT MsiEngineRollbackTransaction( - __in LPCWSTR wzName + __in BURN_ROLLBACK_BOUNDARY* pRollbackBoundary ) { HRESULT hr = S_OK; - UINT uResult = ERROR_SUCCESS; - LogId(REPORT_WARNING, MSG_MSI_TRANSACTION_ROLLBACK, wzName); + LogId(REPORT_WARNING, MSG_MSI_TRANSACTION_ROLLBACK, pRollbackBoundary->sczId); - uResult = ::MsiEndTransaction(MSITRANSACTIONSTATE_ROLLBACK); - ExitOnWin32Error(uResult, hr, "Failed to rollback the MSI transaction"); + hr = WiuEndTransaction(MSITRANSACTIONSTATE_ROLLBACK, WIU_LOG_DEFAULT | INSTALLLOGMODE_VERBOSE, pRollbackBoundary->sczLogPath); + ExitOnFailure(hr, "Failed to rollback the MSI transaction"); LExit: -- cgit v1.2.3-55-g6feb