Skip to content

Commit

Permalink
Block distributed transaction usage on arm64 (dotnet#74226)
Browse files Browse the repository at this point in the history
And fix GUID interop in distributed transactions

See dotnet#74170
  • Loading branch information
roji authored Sep 11, 2022
1 parent abb5c34 commit 8f33fd5
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@
<data name="TraceSourceBase" xml:space="preserve">
<value>[Base]</value>
</data>
<data name="DistributedNotSupportOn32Bits" xml:space="preserve">
<data name="DistributedNotSupportedOn32Bits" xml:space="preserve">
<value>Distributed transactions are currently unsupported in 32-bit processes.</value>
</data>
</root>
<data name="DistributedNotSupportedOnArm" xml:space="preserve">
<value>Distributed transactions are currently unsupported on ARM.</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
internal interface IResourceManagerFactory2
{
internal void Create(
Guid pguidRM,
in Guid pguidRM,
[MarshalAs(UnmanagedType.LPStr)] string pszRMName,
[MarshalAs(UnmanagedType.Interface)] IResourceManagerSink pIResMgrSink,
[MarshalAs(UnmanagedType.Interface)] out IResourceManager rm);

internal void CreateEx(
Guid pguidRM,
in Guid pguidRM,
[MarshalAs(UnmanagedType.LPStr)] string pszRMName,
[MarshalAs(UnmanagedType.Interface)] IResourceManagerSink pIResMgrSink,
Guid riidRequested,
in Guid riidRequested,
[MarshalAs(UnmanagedType.Interface)] out object rm);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// 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;
using System.Transactions.Oletx;

namespace System.Transactions.DtcProxyShim.DtcInterfaces;

Expand All @@ -12,7 +10,7 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
internal interface ITransaction
{
void Commit(
[MarshalAs(UnmanagedType.Bool)] bool fRetainingt,
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
[MarshalAs(UnmanagedType.U4)] OletxXacttc grfTC,
uint grfRM);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace System.Transactions.DtcProxyShim.DtcInterfaces;

// https://docs.microsoft.com/previous-versions/windows/desktop/ms679525(v=vs.85)
// https://docs.microsoft.com/previous-versions/windows/desktop/ms687604(v=vs.85)
[ComImport, Guid(Guids.IID_ITransactionDispenser), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITransactionDispenser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand All @@ -13,6 +12,6 @@ internal interface ITransactionImport
void Import(
uint cbTransactionCookie,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] byte[] rgbTransactionCookie,
Guid piid,
in Guid piid,
[MarshalAs(UnmanagedType.Interface)] out object ppvTransaction);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
[ComImport, Guid("3A6AD9E2-23B9-11cf-AD60-00AA00A74CCD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITransactionOutcomeEvents
{
void Committed([MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW /* always null? */, int hresult);
void Committed(
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
IntPtr pNewUOW,
int hresult);

void Aborted(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW, int hresult);
void Aborted(
IntPtr pboidReason,
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
IntPtr pNewUOW,
int hresult);

void HeuristicDecision([MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision, IntPtr pboidReason, int hresult);
void HeuristicDecision(
[MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision,
IntPtr pboidReason,
int hresult);

void Indoubt();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// 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;
using System.Transactions.Oletx;

namespace System.Transactions.DtcProxyShim.DtcInterfaces;

Expand All @@ -19,7 +17,10 @@ void PrepareRequest(

void CommitRequest(OletxXactRm grfRM, IntPtr pNewUOW);

void AbortRequest(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW);
void AbortRequest(
IntPtr pboidReason,
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
IntPtr pNewUOW);

void TMDown();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ namespace System.Transactions.DtcProxyShim.DtcInterfaces;
[ComImport, Guid("5433376B-414D-11d3-B206-00C04FC2F3EF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITransactionVoterNotifyAsync2
{
void Committed([MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW /* always null? */, uint hresult);
void Committed(
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
IntPtr pNewUOW,
uint hresult);

void Aborted(IntPtr pboidReason, [MarshalAs(UnmanagedType.Bool)] bool fRetaining, IntPtr pNewUOW, uint hresult);
void Aborted(
IntPtr pboidReason,
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,
IntPtr pNewUOW,
uint hresult);

void HeuristicDecision([MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision, IntPtr pboidReason, uint hresult);
void HeuristicDecision(
[MarshalAs(UnmanagedType.U4)] OletxTransactionHeuristic dwDecision,
IntPtr pboidReason,
uint hresult);

void Indoubt();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ public void ConnectToProxy(
out byte[] whereabouts,
out ResourceManagerShim resourceManagerShim)
{
if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
switch (RuntimeInformation.ProcessArchitecture)
{
throw new PlatformNotSupportedException(SR.DistributedNotSupportOn32Bits);
case Architecture.X86:
throw new PlatformNotSupportedException(SR.DistributedNotSupportedOn32Bits);

case Architecture.Armv6: // #74170
case Architecture.Arm64:
throw new PlatformNotSupportedException(SR.DistributedNotSupportedOnArm);
}

ConnectToProxyCore(nodeName, resourceManagerIdentifier, managedIdentifier, out nodeNameMatches, out whereabouts, out resourceManagerShim);
Expand Down

0 comments on commit 8f33fd5

Please sign in to comment.