Skip to content

Commit 51d73dd

Browse files
author
Javad Rahnama
authored
Merge 3ae0b32 into c822b69
2 parents c822b69 + 3ae0b32 commit 51d73dd

File tree

8 files changed

+115
-118
lines changed

8 files changed

+115
-118
lines changed

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.Data.ProviderBase
99
using System.Diagnostics;
1010
using System.Threading.Tasks;
1111
using Microsoft.Data.Common;
12-
using SysTx = System.Transactions;
12+
using System.Transactions;
1313

1414
abstract internal class DbConnectionClosed : DbConnectionInternal
1515
{
@@ -26,12 +26,12 @@ override public string ServerVersion
2626
}
2727
}
2828

29-
override protected void Activate(SysTx.Transaction transaction)
29+
override protected void Activate(Transaction transaction)
3030
{
3131
throw ADP.ClosedConnectionError();
3232
}
3333

34-
override public DbTransaction BeginTransaction(IsolationLevel il)
34+
override public DbTransaction BeginTransaction(System.Data.IsolationLevel il)
3535
{
3636
throw ADP.ClosedConnectionError();
3737
}
@@ -51,7 +51,7 @@ override protected void Deactivate()
5151
throw ADP.ClosedConnectionError();
5252
}
5353

54-
override public void EnlistTransaction(SysTx.Transaction transaction)
54+
override public void EnlistTransaction(Transaction transaction)
5555
{
5656
throw ADP.ClosedConnectionError();
5757
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace Microsoft.Data.ProviderBase
1515
using System.Threading.Tasks;
1616
using Microsoft.Data.Common;
1717
using Microsoft.Data.SqlClient;
18-
using SysTx = System.Transactions;
18+
using System.Transactions;
1919

2020
internal abstract class DbConnectionInternal
2121
{
2222
private static int _objectTypeCount;
2323
internal readonly int _objectID = Interlocked.Increment(ref _objectTypeCount);
24-
private SysTx.TransactionCompletedEventHandler _transactionCompletedEventHandler = null;
24+
private TransactionCompletedEventHandler _transactionCompletedEventHandler = null;
2525

2626
internal static readonly StateChangeEventArgs StateChangeClosed = new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed);
2727
internal static readonly StateChangeEventArgs StateChangeOpen = new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open);
@@ -43,13 +43,13 @@ internal abstract class DbConnectionInternal
4343

4444
private DateTime _createTime; // when the connection was created.
4545

46-
private SysTx.Transaction _enlistedTransaction; // [usage must be thread-safe] the transaction that we're enlisted in, either manually or automatically
46+
private Transaction _enlistedTransaction; // [usage must be thread-safe] the transaction that we're enlisted in, either manually or automatically
4747

4848
// _enlistedTransaction is a clone, so that transaction information can be queried even if the original transaction object is disposed.
4949
// However, there are times when we need to know if the original transaction object was disposed, so we keep a reference to it here.
5050
// This field should only be assigned a value at the same time _enlistedTransaction is updated.
5151
// Also, this reference should not be disposed, since we aren't taking ownership of it.
52-
private SysTx.Transaction _enlistedTransactionOriginal;
52+
private Transaction _enlistedTransactionOriginal;
5353

5454
#if DEBUG
5555
private int _activateCount; // debug only counter to verify activate/deactivates are in sync.
@@ -83,15 +83,15 @@ internal bool CanBePooled
8383
}
8484
}
8585

86-
protected internal SysTx.Transaction EnlistedTransaction
86+
protected internal Transaction EnlistedTransaction
8787
{
8888
get
8989
{
9090
return _enlistedTransaction;
9191
}
9292
set
9393
{
94-
SysTx.Transaction currentEnlistedTransaction = _enlistedTransaction;
94+
Transaction currentEnlistedTransaction = _enlistedTransaction;
9595
if (((null == currentEnlistedTransaction) && (null != value))
9696
|| ((null != currentEnlistedTransaction) && !currentEnlistedTransaction.Equals(value)))
9797
{ // WebData 20000024
@@ -104,8 +104,8 @@ protected internal SysTx.Transaction EnlistedTransaction
104104
// SQLBUDT #230558 we need to use a clone of the transaction
105105
// when we store it, or we'll end up keeping it past the
106106
// duration of the using block of the TransactionScope
107-
SysTx.Transaction valueClone = null;
108-
SysTx.Transaction previousTransactionClone = null;
107+
Transaction valueClone = null;
108+
Transaction previousTransactionClone = null;
109109
try
110110
{
111111
if (null != value)
@@ -188,7 +188,7 @@ protected bool EnlistedTransactionDisposed
188188
{
189189
bool disposed;
190190

191-
SysTx.Transaction currentEnlistedTransactionOriginal = _enlistedTransactionOriginal;
191+
Transaction currentEnlistedTransactionOriginal = _enlistedTransactionOriginal;
192192
if (currentEnlistedTransactionOriginal != null)
193193
{
194194
disposed = currentEnlistedTransactionOriginal.TransactionInformation == null;
@@ -385,9 +385,9 @@ public ConnectionState State
385385

386386
internal virtual bool IsAccessTokenExpired => false;
387387

388-
abstract protected void Activate(SysTx.Transaction transaction);
388+
abstract protected void Activate(Transaction transaction);
389389

390-
internal void ActivateConnection(SysTx.Transaction transaction)
390+
internal void ActivateConnection(Transaction transaction)
391391
{
392392
// Internal method called from the connection pooler so we don't expose
393393
// the Activate method publicly.
@@ -415,7 +415,7 @@ internal void AddWeakReference(object value, int tag)
415415
_referenceCollection.Add(value, tag);
416416
}
417417

418-
abstract public DbTransaction BeginTransaction(IsolationLevel il);
418+
abstract public DbTransaction BeginTransaction(System.Data.IsolationLevel il);
419419

420420
virtual public void ChangeDatabase(string value)
421421
{
@@ -654,7 +654,7 @@ public virtual void Dispose()
654654
// Dispose of the _enlistedTransaction since it is a clone
655655
// of the original reference.
656656
// VSDD 780271 - _enlistedTransaction can be changed by another thread (TX end event)
657-
SysTx.Transaction enlistedTransaction = Interlocked.Exchange(ref _enlistedTransaction, null);
657+
Transaction enlistedTransaction = Interlocked.Exchange(ref _enlistedTransaction, null);
658658
if (enlistedTransaction != null)
659659
{
660660
enlistedTransaction.Dispose();
@@ -681,7 +681,7 @@ protected internal void UnDoomThisConnection()
681681
_connectionIsDoomed = false;
682682
}
683683

684-
abstract public void EnlistTransaction(SysTx.Transaction transaction);
684+
abstract public void EnlistTransaction(Transaction transaction);
685685

686686
virtual protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions)
687687
{
@@ -865,21 +865,21 @@ internal void RemoveWeakReference(object value)
865865
// Cleanup connection's transaction-specific structures (currently used by Delegated transaction).
866866
// This is a separate method because cleanup can be triggered in multiple ways for a delegated
867867
// transaction.
868-
virtual protected void CleanupTransactionOnCompletion(SysTx.Transaction transaction)
868+
virtual protected void CleanupTransactionOnCompletion(Transaction transaction)
869869
{
870870
}
871871

872872
internal void DetachCurrentTransactionIfEnded()
873873
{
874-
SysTx.Transaction enlistedTransaction = EnlistedTransaction;
874+
Transaction enlistedTransaction = EnlistedTransaction;
875875
if (enlistedTransaction != null)
876876
{
877877
bool transactionIsDead;
878878
try
879879
{
880-
transactionIsDead = (SysTx.TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status);
880+
transactionIsDead = (TransactionStatus.Active != enlistedTransaction.TransactionInformation.Status);
881881
}
882-
catch (SysTx.TransactionException)
882+
catch (TransactionException)
883883
{
884884
// If the transaction is being processed (i.e. is part way through a rollback\commit\etc then TransactionInformation.Status will throw an exception)
885885
transactionIsDead = true;
@@ -892,7 +892,7 @@ internal void DetachCurrentTransactionIfEnded()
892892
}
893893

894894
// Detach transaction from connection.
895-
internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitlyReleasing)
895+
internal void DetachTransaction(Transaction transaction, bool isExplicitlyReleasing)
896896
{
897897
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionInternal.DetachTransaction|RES|CPOOL> {0}, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount);
898898

@@ -906,7 +906,7 @@ internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitly
906906
DbConnection owner = Owner;
907907
if (isExplicitlyReleasing || UnbindOnTransactionCompletion || owner is null)
908908
{
909-
SysTx.Transaction currentEnlistedTransaction = _enlistedTransaction;
909+
Transaction currentEnlistedTransaction = _enlistedTransaction;
910910
if (currentEnlistedTransaction != null && transaction.Equals(currentEnlistedTransaction))
911911
{
912912
// We need to remove the transaction completed event handler to cease listening for the transaction to end.
@@ -924,7 +924,7 @@ internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitly
924924
}
925925

926926
// Handle transaction detach, pool cleanup and other post-transaction cleanup tasks associated with
927-
internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transaction)
927+
internal void CleanupConnectionOnTransactionCompletion(Transaction transaction)
928928
{
929929
DetachTransaction(transaction, false);
930930

@@ -935,9 +935,9 @@ internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transac
935935
}
936936
}
937937

938-
void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e)
938+
void TransactionCompletedEvent(object sender, TransactionEventArgs e)
939939
{
940-
SysTx.Transaction transaction = e.Transaction;
940+
Transaction transaction = e.Transaction;
941941
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionInternal.TransactionCompletedEvent|RES|CPOOL> {0}, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount);
942942

943943
CleanupTransactionOnCompletion(transaction);
@@ -947,9 +947,9 @@ void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e)
947947

948948
// TODO: Review whether we need the unmanaged code permission when we have the new object model available.
949949
[SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
950-
private void TransactionOutcomeEnlist(SysTx.Transaction transaction)
950+
private void TransactionOutcomeEnlist(Transaction transaction)
951951
{
952-
_transactionCompletedEventHandler ??= new SysTx.TransactionCompletedEventHandler(TransactionCompletedEvent);
952+
_transactionCompletedEventHandler ??= new TransactionCompletedEventHandler(TransactionCompletedEvent);
953953
transaction.TransactionCompleted += _transactionCompletedEventHandler;
954954
}
955955

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ namespace Microsoft.Data.ProviderBase
1919
using System.Threading.Tasks;
2020
using Microsoft.Data.Common;
2121
using Microsoft.Data.SqlClient;
22-
23-
using SysTx = System.Transactions;
22+
using System.Transactions;
2423

2524
sealed internal class DbConnectionPool
2625
{
@@ -36,8 +35,8 @@ private enum State
3635
// copy as part of the value.
3736
sealed private class TransactedConnectionList : List<DbConnectionInternal>
3837
{
39-
private SysTx.Transaction _transaction;
40-
internal TransactedConnectionList(int initialAllocation, SysTx.Transaction tx) : base(initialAllocation)
38+
private Transaction _transaction;
39+
internal TransactedConnectionList(int initialAllocation, Transaction tx) : base(initialAllocation)
4140
{
4241
_transaction = tx;
4342
}
@@ -69,7 +68,7 @@ public PendingGetConnection(long dueTime, DbConnection owner, TaskCompletionSour
6968
sealed private class TransactedConnectionPool
7069
{
7170

72-
Dictionary<SysTx.Transaction, TransactedConnectionList> _transactedCxns;
71+
Dictionary<Transaction, TransactedConnectionList> _transactedCxns;
7372

7473
DbConnectionPool _pool;
7574

@@ -80,7 +79,7 @@ internal TransactedConnectionPool(DbConnectionPool pool)
8079
{
8180
Debug.Assert(null != pool, "null pool?");
8281
_pool = pool;
83-
_transactedCxns = new Dictionary<SysTx.Transaction, TransactedConnectionList>();
82+
_transactedCxns = new Dictionary<Transaction, TransactedConnectionList>();
8483
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.TransactedConnectionPool.TransactedConnectionPool|RES|CPOOL> {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectID);
8584
}
8685

@@ -100,7 +99,7 @@ internal DbConnectionPool Pool
10099
}
101100
}
102101

103-
internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction)
102+
internal DbConnectionInternal GetTransactedObject(Transaction transaction)
104103
{
105104
Debug.Assert(null != transaction, "null transaction?");
106105

@@ -145,7 +144,7 @@ internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction)
145144
return transactedObject;
146145
}
147146

148-
internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInternal transactedObject)
147+
internal void PutTransactedObject(Transaction transaction, DbConnectionInternal transactedObject)
149148
{
150149
Debug.Assert(null != transaction, "null transaction?");
151150
Debug.Assert(null != transactedObject, "null transactedObject?");
@@ -179,7 +178,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
179178
{
180179
// create the transacted pool, making sure to clone the associated transaction
181180
// for use as a key in our internal dictionary of transactions and connections
182-
SysTx.Transaction transactionClone = null;
181+
Transaction transactionClone = null;
183182
TransactedConnectionList newConnections = null;
184183

185184
try
@@ -243,7 +242,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
243242

244243
}
245244

246-
internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject)
245+
internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
247246
{
248247
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.TransactedConnectionPool.TransactionEnded|RES|CPOOL> {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
249248
TransactedConnectionList connections;
@@ -1014,7 +1013,7 @@ private void DeactivateObject(DbConnectionInternal obj)
10141013
// the transaction asynchronously completing on a second
10151014
// thread.
10161015

1017-
SysTx.Transaction transaction = obj.EnlistedTransaction;
1016+
Transaction transaction = obj.EnlistedTransaction;
10181017
if (null != transaction)
10191018
{
10201019
// NOTE: we're not locking on _state, so it's possible that its
@@ -1212,7 +1211,7 @@ void WaitForPendingOpen()
12121211

12131212
bool allowCreate = true;
12141213
bool onlyOneCheckConnection = false;
1215-
ADP.SetCurrentTransaction(next.Completion.Task.AsyncState as System.Transactions.Transaction);
1214+
ADP.SetCurrentTransaction(next.Completion.Task.AsyncState as Transaction);
12161215
timeout = !TryGetConnection(next.Owner, delay, allowCreate, onlyOneCheckConnection, next.UserOptions, out connection);
12171216
}
12181217
#if DEBUG
@@ -1336,7 +1335,7 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<D
13361335
private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)
13371336
{
13381337
DbConnectionInternal obj = null;
1339-
SysTx.Transaction transaction = null;
1338+
Transaction transaction = null;
13401339

13411340
PerformanceCounters.SoftConnectsPerSecond.Increment();
13421341
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Getting connection.", ObjectID);
@@ -1554,7 +1553,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
15541553
return true;
15551554
}
15561555

1557-
private void PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, SysTx.Transaction transaction)
1556+
private void PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction)
15581557
{
15591558
lock (obj)
15601559
{ // Protect against Clear and ReclaimEmancipatedObjects, which call IsEmancipated, which is affected by PrePush and PostPop
@@ -1631,7 +1630,7 @@ private DbConnectionInternal GetFromGeneralPool()
16311630
return (obj);
16321631
}
16331632

1634-
private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transaction)
1633+
private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
16351634
{
16361635
transaction = ADP.GetCurrentTransaction();
16371636
DbConnectionInternal obj = null;
@@ -1973,7 +1972,7 @@ internal void Shutdown()
19731972
// that is implemented inside DbConnectionPool. This method's counterpart (PutTransactedObject) should
19741973
// only be called from DbConnectionPool.DeactivateObject and thus the plumbing to provide access to
19751974
// other objects is unnecessary (hence the asymmetry of Ended but no Begin)
1976-
internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject)
1975+
internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
19771976
{
19781977
Debug.Assert(null != transaction, "null transaction?");
19791978
Debug.Assert(null != transactedObject, "null transactedObject?");

0 commit comments

Comments
 (0)