Skip to content

Commit 699bdcb

Browse files
committed
Address review comments
1 parent be2a110 commit 699bdcb

16 files changed

+19
-42
lines changed

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITransactionResourceAsync.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal interface ITransactionResourceAsync
2424
/// </summary>
2525
/// <param name="fRetaining">Always false.</param>
2626
/// <param name="grfRM">Values from <see cref="OletxXactRm" />.</param>
27-
/// <param name="fWantMoniker">Always false.</param> // TODO
27+
/// <param name="fWantMoniker">Always false.</param>
2828
/// <param name="fSinglePhase">If true, it indicates that the RM is the only resource manager enlisted on the transaction.</param>
2929
void PrepareRequest(
3030
[MarshalAs(UnmanagedType.Bool)] bool fRetaining,

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void BeginTransaction(
135135
out Guid transactionIdentifier,
136136
out TransactionShim transactionShim)
137137
{
138-
var options = GetCachedOptions();
138+
ITransactionOptions options = GetCachedOptions();
139139

140140
try
141141
{
@@ -197,7 +197,7 @@ public void ReceiveTransaction(
197197
out OletxTransactionIsolationLevel isolationLevel,
198198
out TransactionShim transactionShim)
199199
{
200-
var receiver = GetCachedReceiver();
200+
ITransactionReceiver receiver = GetCachedReceiver();
201201

202202
try
203203
{
@@ -250,7 +250,7 @@ public void GetNotification(
250250

251251
Monitor.Enter(_notificationLock);
252252

253-
var entryRemoved = _notifications.TryDequeue(out NotificationShimBase? notification);
253+
bool entryRemoved = _notifications.TryDequeue(out NotificationShimBase? notification);
254254
if (entryRemoved)
255255
{
256256
managedIdentifier = notification!.EnlistmentIdentifier;

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/EnlistmentNotifyShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal void SetIgnoreSpuriousProxyNotifications()
3333

3434
public void PrepareRequest(bool fRetaining, OletxXactRm grfRM, bool fWantMoniker, bool fSinglePhase)
3535
{
36-
var pEnlistmentAsync = Interlocked.Exchange(ref EnlistmentAsync, null);
36+
ITransactionEnlistmentAsync? pEnlistmentAsync = Interlocked.Exchange(ref EnlistmentAsync, null);
3737

3838
if (pEnlistmentAsync is null)
3939
{

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/Guids.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace System.Transactions.DtcProxyShim;
88

9-
// TODO: Is this the right to manage these COM IIDs?
109
internal static class Guids
1110
{
1211
internal const string IID_ITransactionDispenser = "3A6AD9E1-23B9-11cf-AD60-00AA00A74CCD";

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/OletxHelper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal static void Retry(Action action)
3434
{
3535
int nRetries = MaxRetryCount;
3636

37-
while (nRetries > 0)
37+
while (true)
3838
{
3939
try
4040
{
@@ -43,8 +43,12 @@ internal static void Retry(Action action)
4343
}
4444
catch (COMException e) when (e.ErrorCode == XACT_E_ALREADYINPROGRESS)
4545
{
46+
if (--nRetries == 0)
47+
{
48+
throw;
49+
}
50+
4651
Thread.Sleep(RetryInterval);
47-
nRetries--;
4852
}
4953
}
5054
}

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/ResourceManagerShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void Enlist(
2525
var pEnlistmentNotifyShim = new EnlistmentNotifyShim(_shimFactory, managedIdentifier);
2626
var pEnlistmentShim = new EnlistmentShim(pEnlistmentNotifyShim);
2727

28-
var transaction = transactionShim.Transaction;
28+
ITransaction transaction = transactionShim.Transaction;
2929
ResourceManager!.Enlist(transaction, pEnlistmentNotifyShim, out Guid txUow, out OletxTransactionIsolationLevel isoLevel, out ITransactionEnlistmentAsync pEnlistmentAsync);
3030

3131
pEnlistmentNotifyShim.EnlistmentAsync = pEnlistmentAsync;

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/TransactionShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void GetITransactionNative(out IDtcTransaction transactionNative)
6262

6363
public unsafe byte[] GetPropagationToken()
6464
{
65-
var transmitter = _shimFactory.GetCachedTransmitter(Transaction);
65+
ITransactionTransmitter transmitter = _shimFactory.GetCachedTransmitter(Transaction);
6666

6767
try
6868
{

src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/VoterShim.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal VoterBallotShim(DtcProxyShimFactory shimFactory, VoterNotifyShim notify
1616

1717
public void Vote(bool voteYes)
1818
{
19-
var voteHr = OletxHelper.S_OK;
19+
int voteHr = OletxHelper.S_OK;
2020

2121
if (!voteYes)
2222
{

src/libraries/System.Transactions.Local/src/System/Transactions/NonWindowsUnsupported.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,3 @@ internal static Exception NotSupported()
197197
=> new PlatformNotSupportedException(SR.DistributedNotSupported);
198198
}
199199
}
200-
201-
namespace System.Transactions.Diagnostics
202-
{
203-
}

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxDependentTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void Complete()
4343

4444
Debug.Assert(Disposed == 0, "OletxTransction object is disposed");
4545

46-
int localCompleted = Interlocked.CompareExchange(ref _completed, 1, 0);
46+
int localCompleted = Interlocked.Exchange(ref _completed, 1);
4747
if (localCompleted == 1)
4848
{
4949
throw TransactionException.CreateTransactionCompletedException(DistributedTxId);

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxEnlistment.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ internal OletxEnlistment(
5757
OletxTransaction oletxTransaction)
5858
: base(oletxResourceManager, oletxTransaction)
5959
{
60-
Guid myGuid = Guid.Empty;
61-
6260
// This will get set later by the creator of this object after it
6361
// has enlisted with the proxy.
6462
EnlistmentShim = null;
@@ -88,8 +86,6 @@ internal OletxEnlistment(
8886
OletxResourceManager oletxResourceManager)
8987
: base(oletxResourceManager, null)
9088
{
91-
Guid myGuid = Guid.Empty;
92-
9389
// This will get set later by the creator of this object after it
9490
// has enlisted with the proxy.
9591
EnlistmentShim = null;
@@ -304,7 +300,6 @@ public bool PrepareRequest(bool singlePhase, byte[] prepareInfo)
304300
{
305301
State = OletxEnlistmentState.Preparing;
306302

307-
// TODO: Can this be more efficient.
308303
_prepareInfoByteArray = TransactionManager.GetRecoveryInformation(
309304
OletxResourceManager.OletxTransactionManager.CreationNodeName,
310305
prepareInfo);
@@ -598,7 +593,7 @@ public void Phase0Request(bool abortingHint)
598593
// If we got an abort hint or we are the committable transaction and Commit has not yet been called or the TM went down,
599594
// we don't want to do any more work on the transaction. The abort notifications will be sent by the phase 1
600595
// enlistment
601-
if (_aborting || commitNotYetCalled || _tmWentDown)
596+
if (_aborting || commitNotYetCalled || _tmWentDown)
602597
{
603598
// There is a possible race where we could get the Phase0Request before we are given the
604599
// shim. In that case, we will vote "no" when we are given the shim.
@@ -650,7 +645,6 @@ public void Phase0Request(bool abortingHint)
650645
rmGuidArray[index];
651646
}
652647

653-
// TODO: Seems like this could be more efficient.
654648
_prepareInfoByteArray = TransactionManager.GetRecoveryInformation(
655649
OletxResourceManager.OletxTransactionManager.CreationNodeName,
656650
_proxyPrepareInfoByteArray);

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxResourceManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ internal void ReenlistThread(object? state)
571571
localEnlistment = resourceManager.ReenlistList[0] as OletxEnlistment;
572572
if (localEnlistment == null)
573573
{
574-
//TODO need resource string for this exception.
575574
if (etwLog.IsEnabled())
576575
{
577576
etwLog.InternalError();

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransaction.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ internal OletxTransaction(RealOletxTransaction realOletxTransaction)
119119
RealOletxTransaction.OletxTransactionCreated();
120120
}
121121

122-
// TODO: Do we want to keep supporting this?
123122
protected OletxTransaction(SerializationInfo? serializationInfo, StreamingContext context)
124123
{
125124
if (serializationInfo == null)
@@ -711,7 +710,6 @@ internal OletxVolatileEnlistmentContainer AddDependentClone(bool delayCommit)
711710

712711
if (localPhase0VolatileContainer != null)
713712
{
714-
//CSDMain 91509 - We now synchronize this call with the shim notification trying to call Phase0Request on this container
715713
TakeContainerLock(localPhase0VolatileContainer, ref phase0ContainerLockAcquired);
716714
}
717715

@@ -834,10 +832,7 @@ private static void TakeContainerLock(OletxPhase0VolatileEnlistmentContainer loc
834832
{
835833
if (!phase0ContainerLockAcquired)
836834
{
837-
#pragma warning disable 0618
838-
//@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- ericeil
839835
Monitor.Enter(localPhase0VolatileContainer);
840-
#pragma warning restore 0618
841836
phase0ContainerLockAcquired = true;
842837
}
843838
}

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransactionManager.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ internal static void ShimNotificationCallback(object? state, bool timeout)
105105
// In this case we know that the TM has gone down and we need to exchange
106106
// the native lock for a managed lock.
107107
ProcessingTmDown = true;
108-
#pragma warning disable 0618
109-
//@TODO: This overload of Monitor.Enter is obsolete. Please change this to use Monitor.Enter(ref bool), and remove the pragmas -- ericeil
110108
Monitor.Enter(ProxyShimFactory);
111-
#pragma warning restore 0618
112109
}
113110
else
114111
{
@@ -142,7 +139,6 @@ internal static void ShimNotificationCallback(object? state, bool timeout)
142139
{
143140
if (enlistment2 is OletxPhase0VolatileEnlistmentContainer ph0VolEnlistContainer)
144141
{
145-
//CSDMain 91509 - We now synchronize this call with the AddDependentClone call in RealOleTxTransaction
146142
ph0VolEnlistContainer.Phase0Request(abortingHint);
147143
}
148144
else
@@ -443,7 +439,6 @@ internal OletxCommittableTransaction CreateTransaction(TransactionOptions proper
443439
DtcTransactionManagerLock.AcquireReaderLock(-1);
444440
try
445441
{
446-
// TODO: Make Sys.Tx isolation level values the same as DTC isolation level values and use the sys.tx value here.
447442
OletxTransactionIsolationLevel oletxIsoLevel = ConvertIsolationLevel(properties.IsolationLevel);
448443
uint oletxTimeout = DtcTransactionManager.AdjustTimeout(properties.Timeout);
449444

src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxVolatileEnlistment.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ internal void Phase0Request(bool abortHint)
469469
try
470470
{
471471
_phase0EnlistmentShim.Phase0Done(false);
472-
// CSDMain 138031: There is a potential race between DTC sending Abort notification and OletxDependentTransaction::Complete is called.
473472
// We need to set the alreadyVoted flag to true once we successfully voted, so later we don't vote again when OletxDependentTransaction::Complete is called
474473
// Otherwise, in OletxPhase0VolatileEnlistmentContainer::DecrementOutstandingNotifications code path, we are going to call Phase0Done( true ) again
475474
// and result in an access violation while accessing the pPhase0EnlistmentAsync member variable of the Phase0Shim object.
@@ -592,7 +591,7 @@ internal override void AddDependentClone()
592591
{
593592
if (Phase != -1)
594593
{
595-
throw TransactionException.CreateTransactionStateException(null, Guid.Empty); // TODO
594+
throw TransactionException.CreateTransactionStateException(null, Guid.Empty);
596595
}
597596

598597
// We simply need to block the response to the proxy until all clone is completed.
@@ -614,8 +613,7 @@ internal override void DependentCloneCompleted()
614613
etwLog.MethodEnter(TraceSourceType.TraceSourceOleTx, this, description);
615614
}
616615

617-
//Fix for stress bug CSDMain 126887. This is to synchronize with the corresponding AddDependentClone
618-
//which takes the container lock while incrementing the incompleteDependentClone count
616+
// This is to synchronize with the corresponding AddDependentClone which takes the container lock while incrementing the incompleteDependentClone count
619617
lock (this)
620618
{
621619
IncompleteDependentClones--;

src/libraries/System.Transactions.Local/src/System/Transactions/TransactionInterop.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ public static byte[] GetExportCookie(Transaction transaction, byte[] whereabouts
7878
// (since it is generated by Microsoft code) and the problem is with
7979
// communication. So in this case we default for unknown exceptions to
8080
// assume that the problem is with communication.
81-
82-
// TODO
83-
throw new Exception("TODO");
84-
// throw TransactionManagerCommunicationException.Create(SR.GetString(SR.TraceSourceOletx), comException);
81+
throw TransactionManagerCommunicationException.Create(null, comException);
8582
}
8683

8784
if (etwLog.IsEnabled())

0 commit comments

Comments
 (0)