Skip to content

Commit

Permalink
Remove OnSetUpdate/OnSetUpdateComplete that deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Mar 1, 2024
1 parent 7d141da commit 1c914cc
Show file tree
Hide file tree
Showing 33 changed files with 94 additions and 544 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ typedef struct _BAENGINE_SETUPDATE_ARGS
DWORD64 qwSize;
BOOTSTRAPPER_UPDATE_HASH_TYPE hashType;
LPCWSTR wzHash;
LPCWSTR wzUpdatePackageId;
} BAENGINE_SETUPDATE_ARGS;

typedef struct _BAENGINE_SETUPDATE_RESULTS
Expand Down
25 changes: 0 additions & 25 deletions src/api/burn/WixToolset.BootstrapperCore.Native/inc/batypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ enum BOOTSTRAPPER_APPLICATION_MESSAGE
BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTCOMPLETE,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPAYLOADEXTRACTPROGRESS,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATEBEGIN,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATECOMPLETE,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGEBEGIN,
BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANCOMPATIBLEMSIPACKAGECOMPLETE,
Expand Down Expand Up @@ -1481,29 +1479,6 @@ struct BA_ONROLLBACKMSITRANSACTIONCOMPLETE_RESULTS
BOOTSTRAPPER_EXECUTEMSITRANSACTIONCOMPLETE_ACTION action;
};

struct BA_ONSETUPDATEBEGIN_ARGS
{
DWORD cbSize;
};

struct BA_ONSETUPDATEBEGIN_RESULTS
{
DWORD cbSize;
};

struct BA_ONSETUPDATECOMPLETE_ARGS
{
DWORD cbSize;
HRESULT hrStatus;
LPCWSTR wzPreviousPackageId;
LPCWSTR wzNewPackageId;
};

struct BA_ONSETUPDATECOMPLETE_RESULTS
{
DWORD cbSize;
};

struct BA_ONSHUTDOWN_ARGS
{
DWORD cbSize;
Expand Down
47 changes: 0 additions & 47 deletions src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,6 @@ public abstract class BootstrapperApplication : MarshalByRefObject, IDefaultBoot
/// <inheritdoc/>
public event EventHandler<CachePayloadExtractCompleteEventArgs> CachePayloadExtractComplete;

/// <inheritdoc/>
public event EventHandler<SetUpdateBeginEventArgs> SetUpdateBegin;

/// <inheritdoc/>
public event EventHandler<SetUpdateCompleteEventArgs> SetUpdateComplete;

/// <inheritdoc/>
public event EventHandler<PlanRestoreRelatedBundleEventArgs> PlanRestoreRelatedBundle;

Expand Down Expand Up @@ -1345,31 +1339,6 @@ protected virtual void OnCachePayloadExtractComplete(CachePayloadExtractComplete
}
}

/// <summary>
/// Called by the engine, raises the <see cref="SetUpdateBegin"/> event.
/// </summary>
/// <param name="args">Additional arguments for this event.</param>
protected virtual void OnSetUpdateBegin(SetUpdateBeginEventArgs args)
{
EventHandler<SetUpdateBeginEventArgs> handler = this.SetUpdateBegin;
if (null != handler)
{
handler(this, args);
}
}

/// <summary>
/// Called by the engine, raises the <see cref="SetUpdateComplete"/> event.
/// </summary>
/// <param name="args">Additional arguments for this event.</param>
protected virtual void OnSetUpdateComplete(SetUpdateCompleteEventArgs args)
{
EventHandler<SetUpdateCompleteEventArgs> handler = this.SetUpdateComplete;
if (null != handler)
{
handler(this, args);
}
}

/// <summary>
/// Called by the engine, raises the <see cref="PlanRestoreRelatedBundle"/> event.
Expand Down Expand Up @@ -2153,22 +2122,6 @@ int IBootstrapperApplication.OnCachePayloadExtractComplete(string wzContainerId,
return args.HResult;
}

int IBootstrapperApplication.OnSetUpdateBegin()
{
SetUpdateBeginEventArgs args = new SetUpdateBeginEventArgs();
this.OnSetUpdateBegin(args);

return args.HResult;
}

int IBootstrapperApplication.OnSetUpdateComplete(int hrStatus, string wzPreviousPackageId, string wzNewPackageId)
{
SetUpdateCompleteEventArgs args = new SetUpdateCompleteEventArgs(hrStatus, wzPreviousPackageId, wzNewPackageId);
this.OnSetUpdateComplete(args);

return args.HResult;
}

int IBootstrapperApplication.OnPlanRestoreRelatedBundle(string wzBundleId, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel)
{
PlanRestoreRelatedBundleEventArgs args = new PlanRestoreRelatedBundleEventArgs(wzBundleId, recommendedState, pRequestedState, fCancel);
Expand Down
8 changes: 4 additions & 4 deletions src/api/burn/WixToolset.Mba.Core/BundleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ internal BundleInfo()
}

/// <inheritdoc/>
public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e)
public IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version)
{
var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version);
var package = PackageInfo.GetRelatedBundleAsPackage(productCode, relationType, perMachine, version);
this.Packages.Add(package.Id, package);
return package;
}

/// <inheritdoc/>
public IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e)
public IPackageInfo AddUpdateBundleAsPackage(string packageId)
{
var package = PackageInfo.GetUpdateBundleAsPackage(e.NewPackageId);
var package = PackageInfo.GetUpdateBundleAsPackage(packageId);
this.Packages.Add(package.Id, package);
return package;
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/burn/WixToolset.Mba.Core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ public void Plan(LaunchAction action)
}

/// <inheritdoc/>
public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash)
public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId)
{
this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash);
this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, updatePackageId);
}

/// <inheritdoc/>
Expand Down
43 changes: 0 additions & 43 deletions src/api/burn/WixToolset.Mba.Core/EventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2614,49 +2614,6 @@ public CachePayloadExtractCompleteEventArgs(string containerId, string payloadId
public string PayloadId { get; private set; }
}

/// <summary>
/// EventArgs for <see cref="IDefaultBootstrapperApplication.SetUpdateBegin"/>.
/// </summary>
[Serializable]
public class SetUpdateBeginEventArgs : HResultEventArgs
{
/// <summary>
/// This class is for events raised by the engine.
/// It is not intended to be instantiated by user code.
/// </summary>
public SetUpdateBeginEventArgs()
{
}
}

/// <summary>
/// Event arguments for <see cref="IDefaultBootstrapperApplication.SetUpdateComplete"/>
/// </summary>
[Serializable]
public class SetUpdateCompleteEventArgs : StatusEventArgs
{
/// <summary>
/// This class is for events raised by the engine.
/// It is not intended to be instantiated by user code.
/// </summary>
public SetUpdateCompleteEventArgs(int hrStatus, string previousPackageId, string newPackageId)
: base(hrStatus)
{
this.PreviousPackageId = previousPackageId;
this.NewPackageId = newPackageId;
}

/// <summary>
/// Gets the identifier of the update package that was removed.
/// </summary>
public string PreviousPackageId { get; private set; }

/// <summary>
/// Gets the identifier of the update package that was added.
/// </summary>
public string NewPackageId { get; private set; }
}

/// <summary>
/// Event arguments for <see cref="IDefaultBootstrapperApplication.PlanRestoreRelatedBundle"/>
/// </summary>
Expand Down
18 changes: 0 additions & 18 deletions src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -951,24 +951,6 @@ int OnCachePayloadExtractComplete(
int hrStatus
);

/// <summary>
/// See <see cref="IDefaultBootstrapperApplication.SetUpdateBegin"/>.
/// </summary>
[PreserveSig]
[return: MarshalAs(UnmanagedType.I4)]
int OnSetUpdateBegin();

/// <summary>
/// See <see cref="IDefaultBootstrapperApplication.SetUpdateComplete"/>.
/// </summary>
[PreserveSig]
[return: MarshalAs(UnmanagedType.I4)]
int OnSetUpdateComplete(
int hrStatus,
[MarshalAs(UnmanagedType.LPWStr)] string wzPreviousPackageId,
[MarshalAs(UnmanagedType.LPWStr)] string wzNewPackageId
);

/// <summary>
/// See <see cref="IDefaultBootstrapperApplication.PlanRestoreRelatedBundle"/>.
/// </summary>
Expand Down
9 changes: 5 additions & 4 deletions src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ void SendEmbeddedProgress(
);

/// <summary>
/// See <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string)"/>.
/// See <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/>.
/// </summary>
void SetUpdate(
[MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource,
[MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource,
[MarshalAs(UnmanagedType.U8)] long qwValue,
[MarshalAs(UnmanagedType.U4)] UpdateHashType hashType,
[MarshalAs(UnmanagedType.LPWStr)] string wzHash
[MarshalAs(UnmanagedType.LPWStr)] string wzHash,
[MarshalAs(UnmanagedType.LPWStr)] string wzUpdatePackageId
);

/// <summary>
Expand Down Expand Up @@ -330,12 +331,12 @@ public enum LaunchAction
Repair,

/// <summary>
/// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string)"/> and then exit without waiting for it to complete.
/// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/> and then exit without waiting for it to complete.
/// </summary>
UpdateReplace,

/// <summary>
/// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string)"/> as an embedded bundle.
/// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/> as an embedded bundle.
/// </summary>
UpdateReplaceEmbedded,
}
Expand Down
11 changes: 7 additions & 4 deletions src/api/burn/WixToolset.Mba.Core/IBundleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ public interface IBundleInfo
/// <summary>
/// Adds a related bundle as a package.
/// </summary>
/// <param name="e"></param>
/// <param name="productCode"></param>
/// <param name="relationType"></param>
/// <param name="perMachine"></param>
/// <param name="version"></param>
/// <returns>The created <see cref="IPackageInfo"/>.</returns>
IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e);
IPackageInfo AddRelatedBundleAsPackage(string productCode, RelationType relationType, bool perMachine, string version);

/// <summary>
/// Adds an update bundle as a package.
/// </summary>
/// <param name="e"></param>
/// <param name="packageId">Package id added as update bundle.</param>
/// <returns>The created <see cref="IPackageInfo"/>.</returns>
IPackageInfo AddUpdateBundleAsPackage(SetUpdateCompleteEventArgs e);
IPackageInfo AddUpdateBundleAsPackage(string packageId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,6 @@ public interface IDefaultBootstrapperApplication : IBootstrapperApplication
/// </summary>
event EventHandler<RollbackMsiTransactionCompleteEventArgs> RollbackMsiTransactionComplete;

/// <summary>
/// Fired when the engine has begun to setup the update package.
/// </summary>
event EventHandler<SetUpdateBeginEventArgs> SetUpdateBegin;

/// <summary>
/// Fired when the engine has completed setting up the update package.
/// </summary>
event EventHandler<SetUpdateCompleteEventArgs> SetUpdateComplete;

/// <summary>
/// Fired when the engine is shutting down the bootstrapper application.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/api/burn/WixToolset.Mba.Core/IEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public interface IEngine
/// <param name="size">Size of the expected update.</param>
/// <param name="hashType">Type of the hash expected on the update.</param>
/// <param name="hash">Optional hash expected for the update.</param>
void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash);
/// <param name="updatePackageId">Optional package id for the update.</param>
void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash, string updatePackageId);

/// <summary>
/// Sets the URL to the update feed.
Expand Down
24 changes: 0 additions & 24 deletions src/api/burn/balutil/BalBaseBAFunctionsProc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,24 +704,6 @@ static HRESULT BalBaseBAFunctionsProcOnCachePayloadExtractComplete(
return pBAFunctions->OnCachePayloadExtractComplete(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->hrStatus);
}

static HRESULT BalBaseBAFunctionsProcOnSetUpdateBegin(
__in IBAFunctions* pBAFunctions,
__in BA_ONSETUPDATEBEGIN_ARGS* /*pArgs*/,
__inout BA_ONSETUPDATEBEGIN_RESULTS* /*pResults*/
)
{
return pBAFunctions->OnSetUpdateBegin();
}

static HRESULT BalBaseBAFunctionsProcOnSetUpdateComplete(
__in IBAFunctions* pBAFunctions,
__in BA_ONSETUPDATECOMPLETE_ARGS* pArgs,
__inout BA_ONSETUPDATECOMPLETE_RESULTS* /*pResults*/
)
{
return pBAFunctions->OnSetUpdateComplete(pArgs->hrStatus, pArgs->wzPreviousPackageId, pArgs->wzNewPackageId);
}

static HRESULT BalBaseBAFunctionsProcOnPlanRestoreRelatedBundle(
__in IBAFunctions* pBAFunctions,
__in BA_ONPLANRESTORERELATEDBUNDLE_ARGS* pArgs,
Expand Down Expand Up @@ -1062,12 +1044,6 @@ HRESULT WINAPI BalBaseBAFunctionsProc(
case BA_FUNCTIONS_MESSAGE_ONPLANROLLBACKBOUNDARY:
hr = BalBaseBAFunctionsProcOnPlanRollbackBoundary(pBAFunctions, reinterpret_cast<BA_ONPLANROLLBACKBOUNDARY_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANROLLBACKBOUNDARY_RESULTS*>(pvResults));
break;
case BA_FUNCTIONS_MESSAGE_ONSETUPDATEBEGIN:
hr = BalBaseBAFunctionsProcOnSetUpdateBegin(pBAFunctions, reinterpret_cast<BA_ONSETUPDATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONSETUPDATEBEGIN_RESULTS*>(pvResults));
break;
case BA_FUNCTIONS_MESSAGE_ONSETUPDATECOMPLETE:
hr = BalBaseBAFunctionsProcOnSetUpdateComplete(pBAFunctions, reinterpret_cast<BA_ONSETUPDATECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONSETUPDATECOMPLETE_RESULTS*>(pvResults));
break;
case BA_FUNCTIONS_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE:
hr = BalBaseBAFunctionsProcOnDetectCompatiblePackage(pBAFunctions, reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS*>(pvResults));
break;
Expand Down
24 changes: 0 additions & 24 deletions src/api/burn/balutil/BalBaseBootstrapperApplicationProc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,6 @@ static HRESULT BalBaseBAProcOnCachePayloadExtractComplete(
return pBA->OnCachePayloadExtractComplete(pArgs->wzContainerId, pArgs->wzPayloadId, pArgs->hrStatus);
}

static HRESULT BalBaseBAProcOnSetUpdateBegin(
__in IBootstrapperApplication* pBA,
__in BA_ONSETUPDATEBEGIN_ARGS* /*pArgs*/,
__inout BA_ONSETUPDATEBEGIN_RESULTS* /*pResults*/
)
{
return pBA->OnSetUpdateBegin();
}

static HRESULT BalBaseBAProcOnSetUpdateComplete(
__in IBootstrapperApplication* pBA,
__in BA_ONSETUPDATECOMPLETE_ARGS* pArgs,
__inout BA_ONSETUPDATECOMPLETE_RESULTS* /*pResults*/
)
{
return pBA->OnSetUpdateComplete(pArgs->hrStatus, pArgs->wzPreviousPackageId, pArgs->wzNewPackageId);
}

static HRESULT BalBaseBAProcOnPlanRestoreRelatedBundle(
__in IBootstrapperApplication* pBA,
__in BA_ONPLANRESTORERELATEDBUNDLE_ARGS* pArgs,
Expand Down Expand Up @@ -989,12 +971,6 @@ HRESULT WINAPI BalBaseBootstrapperApplicationProc(
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONPLANROLLBACKBOUNDARY:
hr = BalBaseBAProcOnPlanRollbackBoundary(pBA, reinterpret_cast<BA_ONPLANROLLBACKBOUNDARY_ARGS*>(pvArgs), reinterpret_cast<BA_ONPLANROLLBACKBOUNDARY_RESULTS*>(pvResults));
break;
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATEBEGIN:
hr = BalBaseBAProcOnSetUpdateBegin(pBA, reinterpret_cast<BA_ONSETUPDATEBEGIN_ARGS*>(pvArgs), reinterpret_cast<BA_ONSETUPDATEBEGIN_RESULTS*>(pvResults));
break;
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONSETUPDATECOMPLETE:
hr = BalBaseBAProcOnSetUpdateComplete(pBA, reinterpret_cast<BA_ONSETUPDATECOMPLETE_ARGS*>(pvArgs), reinterpret_cast<BA_ONSETUPDATECOMPLETE_RESULTS*>(pvResults));
break;
case BOOTSTRAPPER_APPLICATION_MESSAGE_ONDETECTCOMPATIBLEMSIPACKAGE:
hr = BalBaseBAProcOnDetectCompatiblePackage(pBA, reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_ARGS*>(pvArgs), reinterpret_cast<BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS*>(pvResults));
break;
Expand Down
Loading

0 comments on commit 1c914cc

Please sign in to comment.