Skip to content

Commit

Permalink
Port distributed transaction support for Windows (#72051)
Browse files Browse the repository at this point in the history
Closes #715
  • Loading branch information
roji authored Aug 12, 2022
1 parent 6a2c63f commit c55d76d
Show file tree
Hide file tree
Showing 77 changed files with 10,091 additions and 755 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ internal static partial class Libraries
internal const string MsQuic = "msquic.dll";
internal const string HostPolicy = "hostpolicy.dll";
internal const string Ucrtbase = "ucrtbase.dll";
internal const string Xolehlp = "xolehlp.dll";
}
}
405 changes: 367 additions & 38 deletions src/libraries/System.Transactions.Local/src/Resources/Strings.resx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)</TargetFrameworks>
<NoWarn>CA1805;IDE0059;CS1591</NoWarn>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<IsTrimmable>false</IsTrimmable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Transactions\CommittableTransaction.cs" />
<Compile Include="System\Transactions\DependentTransaction.cs" />
<Compile Include="System\Transactions\DistributedTransaction.cs" />
<Compile Include="System\Transactions\DurableEnlistmentState.cs" />
<Compile Include="System\Transactions\EnterpriseServices.cs" />
<Compile Include="System\Transactions\Enlistment.cs" />
<Compile Include="System\Transactions\EnlistmentState.cs" />
<Compile Include="System\Transactions\EnlistmentTraceIdentifier.cs" />
<Compile Include="System\Transactions\IDtcTransaction.cs" />
<Compile Include="System\Transactions\IEnlistmentNotification.cs" />
<Compile Include="System\Transactions\InternalTransaction.cs" />
<Compile Include="System\Transactions\IPromotableSinglePhaseNotification.cs" />
Expand All @@ -25,7 +28,6 @@
<Compile Include="System\Transactions\Transaction.cs" />
<Compile Include="System\Transactions\TransactionException.cs" />
<Compile Include="System\Transactions\TransactionInformation.cs" />
<Compile Include="System\Transactions\TransactionInterop.cs" />
<Compile Include="System\Transactions\TransactionManager.cs" />
<Compile Include="System\Transactions\TransactionOptions.cs" />
<Compile Include="System\Transactions\TransactionScope.cs" />
Expand All @@ -40,13 +42,80 @@
<Compile Include="System\Transactions\Configuration\DefaultSettingsSection.cs" />
<Compile Include="System\Transactions\Configuration\MachineSettingsSection.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs" Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IPrepareInfo.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManagerFactory2.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManager.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\IResourceManagerSink.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITmNodeName.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransaction.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionCloner.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionExport.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionExportFactory.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionOptions.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionDispenser.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionEnlistmentAsync.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionImport.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionImportWhereabouts.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionOutcomeEvents.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0EnlistmentAsync.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0Factory.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionPhase0NotifyAsync.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionReceiver.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionReceiverFactory.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionResourceAsync.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionTransmitter.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionTransmitterFactory.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterBallotAsync2.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterFactory2.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcInterfaces\ITransactionVoterNotifyAsync2.cs" />
<Compile Include="System\Transactions\DtcProxyShim\DtcProxyShimFactory.cs" />
<Compile Include="System\Transactions\DtcProxyShim\EnlistmentNotifyShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\EnlistmentShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\Guids.cs" />
<Compile Include="System\Transactions\DtcProxyShim\NativeEnums.cs" />
<Compile Include="System\Transactions\DtcProxyShim\NotificationShimBase.cs" />
<Compile Include="System\Transactions\DtcProxyShim\OletxHelper.cs" />
<Compile Include="System\Transactions\DtcProxyShim\OletxXactTransInfo.cs" />
<Compile Include="System\Transactions\DtcProxyShim\Phase0NotifyShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\Phase0Shim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\ResourceManagerNotifyShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\ResourceManagerShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\TransactionNotifyShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\TransactionOutcome.cs" />
<Compile Include="System\Transactions\DtcProxyShim\TransactionShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\VoterNotifyShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\VoterShim.cs" />
<Compile Include="System\Transactions\DtcProxyShim\Xactopt.cs" />
<Compile Include="System\Transactions\Oletx\DtcTransactionManager.cs" />
<Compile Include="System\Transactions\Oletx\OletxCommittableTransaction.cs" />
<Compile Include="System\Transactions\Oletx\OletxDependentTransaction.cs" />
<Compile Include="System\Transactions\Oletx\OletxEnlistment.cs" />
<Compile Include="System\Transactions\Oletx\OletxResourceManager.cs" />
<Compile Include="System\Transactions\Oletx\OletxTransaction.cs" />
<Compile Include="System\Transactions\Oletx\OletxTransactionManager.cs" />
<Compile Include="System\Transactions\Oletx\OletxVolatileEnlistment.cs" />
<Compile Include="System\Transactions\TransactionInterop.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
<Compile Include="System\Transactions\TransactionInteropNonWindows.cs" />
<Compile Include="System\Transactions\NonWindowsUnsupported.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.Diagnostics.Process" />
<Reference Include="System.Diagnostics.TraceSource" />
<Reference Include="System.Diagnostics.Tracing" />
<Reference Include="System.Memory" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Thread" />
<Reference Include="System.Threading.ThreadPool" />
<Reference Include="System.Xml.ReaderWriter" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Runtime.Versioning;
using System.Threading;

#pragma warning disable CS1591

namespace System.Transactions
{
[UnsupportedOSPlatform("browser")]
Expand Down Expand Up @@ -37,7 +39,7 @@ internal CommittableTransaction(IsolationLevel isoLevel, TimeSpan timeout) : bas
TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
if (etwLog.IsEnabled())
{
etwLog.TransactionCreated(this, "CommittableTransaction");
etwLog.TransactionCreated(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
}
}

Expand All @@ -47,7 +49,7 @@ public IAsyncResult BeginCommit(AsyncCallback? asyncCallback, object? asyncState
if (etwLog.IsEnabled())
{
etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
etwLog.TransactionCommit(this, "CommittableTransaction");
etwLog.TransactionCommit(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
}

ObjectDisposedException.ThrowIf(Disposed, this);
Expand Down Expand Up @@ -81,7 +83,7 @@ public void Commit()
if (etwLog.IsEnabled())
{
etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
etwLog.TransactionCommit(this, "CommittableTransaction");
etwLog.TransactionCommit(TraceSourceType.TraceSourceLtm, TransactionTraceId, "CommittableTransaction");
}

ObjectDisposedException.ThrowIf(Disposed, this);
Expand Down Expand Up @@ -113,7 +115,6 @@ public void Commit()
{
etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
}

}

internal override void InternalDispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void Complete()

if (etwLog.IsEnabled())
{
etwLog.TransactionDependentCloneComplete(this, "DependentTransaction");
etwLog.TransactionDependentCloneComplete(TraceSourceType.TraceSourceLtm, TransactionTraceId, "DependentTransaction");
etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

namespace System.Transactions.DtcProxyShim.DtcInterfaces;

// https://docs.microsoft.com/previous-versions/windows/desktop/ms686533(v=vs.85)
[ComImport, Guid("80c7bfd0-87ee-11ce-8081-0080c758527e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPrepareInfo
{
void GetPrepareInfoSize(out uint pcbPrepInfo);

void GetPrepareInfo([MarshalAs(UnmanagedType.LPArray), Out] byte[] pPrepInfo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace System.Transactions.DtcProxyShim.DtcInterfaces;

// https://docs.microsoft.com/previous-versions/windows/desktop/ms681790(v=vs.85)
[ComImport, Guid(Guids.IID_IResourceManager), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IResourceManager
{
internal void Enlist(
[MarshalAs(UnmanagedType.Interface)] ITransaction pTransaction,
[MarshalAs(UnmanagedType.Interface)] ITransactionResourceAsync pRes,
out Guid pUOW,
out OletxTransactionIsolationLevel pisoLevel,
[MarshalAs(UnmanagedType.Interface)] out ITransactionEnlistmentAsync ppEnlist);

internal void Reenlist(
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pPrepInfo,
uint cbPrepInfom,
uint lTimeout,
[MarshalAs(UnmanagedType.I4)] out OletxXactStat pXactStat);

void ReenlistmentComplete();

void GetDistributedTransactionManager(
in Guid riid,
[MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}
Loading

0 comments on commit c55d76d

Please sign in to comment.