Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private void PruneConnectionPoolGroups(object state)
// distributed transactions that need it.
lock (_poolsToRelease)
{
if (0 != _poolsToRelease.Count)
if (_poolsToRelease.Count != 0)
{
DbConnectionPool[] poolsToRelease = _poolsToRelease.ToArray();
foreach (DbConnectionPool pool in poolsToRelease)
Expand All @@ -307,7 +307,7 @@ private void PruneConnectionPoolGroups(object state)
{
pool.Clear();

if (0 == pool.Count)
if (pool.Count == 0)
{
_poolsToRelease.Remove(pool);
SqlClientEventSource.Log.TryAdvancedTraceEvent("<prov.DbConnectionFactory.PruneConnectionPoolGroups|RES|INFO|CPOOL> {0}, ReleasePool={1}", ObjectID, pool.ObjectID);
Expand All @@ -323,7 +323,7 @@ private void PruneConnectionPoolGroups(object state)
// empty, it's because there are active pools that need it.
lock (_poolGroupsToRelease)
{
if (0 != _poolGroupsToRelease.Count)
if (_poolGroupsToRelease.Count != 0)
{
DbConnectionPoolGroup[] poolGroupsToRelease = _poolGroupsToRelease.ToArray();
foreach (DbConnectionPoolGroup poolGroup in poolGroupsToRelease)
Expand All @@ -332,7 +332,7 @@ private void PruneConnectionPoolGroups(object state)
{
int poolsLeft = poolGroup.Clear(); // may add entries to _poolsToRelease

if (0 == poolsLeft)
if (poolsLeft == 0)
{
_poolGroupsToRelease.Remove(poolGroup);
SqlClientEventSource.Log.TryAdvancedTraceEvent("<prov.DbConnectionFactory.PruneConnectionPoolGroups|RES|INFO|CPOOL> {0}, ReleasePoolGroup={1}", ObjectID, poolGroup.ObjectID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal abstract partial class DbConnectionInternal

private DbConnectionPool _connectionPool; // the pooler that the connection came from (Pooled connections only)
private DbReferenceCollection _referenceCollection; // collection of objects that we need to notify in some way when we're being deactivated
private int _pooledCount; // [usage must be thread safe] the number of times this object has been pushed into the pool less the number of times it's been popped (0 != inPool)
private int _pooledCount; // [usage must be thread safe] the number of times this object has been pushed into the pool less the number of times it's been popped (inPool != 0)

private bool _connectionIsDoomed; // true when the connection should no longer be used.
private bool _cannotBePooled; // true when the connection should no longer be pooled.
Expand Down Expand Up @@ -382,7 +382,7 @@ internal void PrePush(object expectedOwner)
{
throw ADP.InternalError(ADP.InternalErrorCode.UnpooledObjectHasWrongOwner); // unpooled object has incorrect owner
}
if (0 != _pooledCount)
if (_pooledCount != 0)
{
throw ADP.InternalError(ADP.InternalErrorCode.PushingObjectSecondTime); // pushing object onto stack a second time
}
Expand Down Expand Up @@ -420,12 +420,12 @@ internal void PostPop(DbConnection newOwner)
//3 // The following tests are retail assertions of things we can't allow to happen.
if (Pool != null)
{
if (0 != _pooledCount)
if (_pooledCount != 0)
{
throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectInPoolMoreThanOnce); // popping object off stack with multiple pooledCount
}
}
else if (-1 != _pooledCount)
else if (_pooledCount != -1)
{
throw ADP.InternalError(ADP.InternalErrorCode.NonPooledObjectUsedMoreThanOnce); // popping object off stack with multiple pooledCount
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal void ActivateConnection(Transaction transaction)

#if DEBUG
int activateCount = Interlocked.Increment(ref _activateCount);
Debug.Assert(1 == activateCount, "activated multiple times?");
Debug.Assert(activateCount == 1, "activated multiple times?");
#endif // DEBUG

Activate(transaction);
Expand Down Expand Up @@ -342,7 +342,7 @@ virtual internal void DelegatedTransactionEnded()
// ReclaimEmancipatedObjects.
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionInternal.DelegatedTransactionEnded|RES|CPOOL> {0}, Delegated Transaction Completed.", ObjectID);

if (1 == _pooledCount)
if (_pooledCount == 1)
{
// When _pooledCount is 1, it indicates a closed, pooled,
// connection so it is ready to put back into the pool for
Expand All @@ -360,7 +360,7 @@ virtual internal void DelegatedTransactionEnded()
}
pool.PutObjectFromTransactedPool(this);
}
else if (-1 == _pooledCount && !_owningObject.TryGetTarget(out _))
else if (_pooledCount == -1 && !_owningObject.TryGetTarget(out _))
{
// When _pooledCount is -1 and the owning object no longer exists,
// it indicates a closed (or leaked), non-pooled connection so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ internal DbConnectionInternal GetTransactedObject(Transaction transaction)
lock (connections)
{
int i = connections.Count - 1;
if (0 <= i)
if (i >= 0)
{
transactedObject = connections[i];
connections.RemoveAt(i);
Expand Down Expand Up @@ -159,7 +159,7 @@ internal void PutTransactedObject(Transaction transaction, DbConnectionInternal
// synchronize multi-threaded access with GetTransactedObject
lock (connections)
{
Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?");
Debug.Assert(connections.IndexOf(transactedObject) < 0, "adding to pool a second time?");
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.TransactedConnectionPool.PutTransactedObject|RES|CPOOL> {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
connections.Add(transactedObject);
}
Expand Down Expand Up @@ -194,7 +194,7 @@ internal void PutTransactedObject(Transaction transaction, DbConnectionInternal
// synchronize multi-threaded access with GetTransactedObject
lock (connections)
{
Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?");
Debug.Assert(connections.IndexOf(transactedObject) < 0, "adding to pool a second time?");
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.TransactedConnectionPool.PutTransactedObject|RES|CPOOL> {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
connections.Add(transactedObject);
}
Expand Down Expand Up @@ -268,7 +268,7 @@ internal void TransactionEnded(Transaction transaction, DbConnectionInternal tra

// Once we've completed all the ended notifications, we can
// safely remove the list from the transacted pool.
if (0 >= connections.Count)
if (connections.Count <= 0)
{
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.TransactedConnectionPool.TransactionEnded|RES|CPOOL> {0}, Transaction {1}, Removing List from transacted pool.", ObjectID, transaction.GetHashCode());
_transactedCxns.Remove(transaction);
Expand All @@ -292,7 +292,7 @@ internal void TransactionEnded(Transaction transaction, DbConnectionInternal tra

// If (and only if) we found the connection in the list of
// connections, we'll put it back...
if (0 <= entry)
if (entry >= 0)
{
SqlClientEventSource.Log.ExitFreeConnection();
Pool.PutObjectFromTransactedPool(transactedObject);
Expand Down Expand Up @@ -816,7 +816,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio

Debug.Assert(timerIsNotDisposed, "ErrorCallback timer has been disposed");

if (30000 < _errorWait)
if (_errorWait > 30000)
{
_errorWait = 60000;
}
Expand Down Expand Up @@ -1239,12 +1239,12 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
// we reached MaxPoolSize. If so, we will no longer wait on
// the CreationHandle, but instead wait for a free object or
// the timeout.
if (Count >= MaxPoolSize && 0 != MaxPoolSize)
if (Count >= MaxPoolSize && MaxPoolSize != 0)
{
if (!ReclaimEmancipatedObjects())
{
// modify handle array not to wait on creation mutex anymore
Debug.Assert(2 == CREATION_HANDLE, "creation handle changed value");
Debug.Assert(CREATION_HANDLE == 2, "creation handle changed value");
allowCreate = false;
}
}
Expand Down Expand Up @@ -1753,7 +1753,7 @@ private DbConnectionInternal UserCreateRequest(DbConnection owningObject, DbConn
}
else
{
if ((oldConnection != null) || (Count < MaxPoolSize) || (0 == MaxPoolSize))
if ((oldConnection != null) || (Count < MaxPoolSize) || MaxPoolSize == 0)
{
// If we have an odd number of total objects, reclaim any dead objects.
// If we did not find any objects to reclaim, create a new one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ internal void Add(byte[] encryptedKey, int databaseId, int cekId, int cekVersion
};
_columnEncryptionKeyValues.Add(encryptionKey);

if (0 == _databaseId)
if (_databaseId == 0)
{
_databaseId = databaseId;
_cekId = cekId;
Expand Down Expand Up @@ -202,7 +202,7 @@ internal class SqlTceCipherInfoTable

internal SqlTceCipherInfoTable(int tabSize)
{
Debug.Assert(0 < tabSize, "Invalid Table Size");
Debug.Assert(tabSize > 0, "Invalid Table Size");
keyList = new SqlTceCipherInfoEntry[tabSize];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i

StringBuilder updateBulkCommandText = new StringBuilder();

if (0 == internalResults[CollationResultId].Count)
if (internalResults[CollationResultId].Count == 0)
{
throw SQL.BulkLoadNoCollation();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e
throw SQL.NullEncryptedColumnEncryptionKey();
}

if (0 == encryptedColumnEncryptionKey.Length)
if (encryptedColumnEncryptionKey.Length == 0)
{
throw SQL.EmptyEncryptedColumnEncryptionKey();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e
{
throw SQL.NullColumnEncryptionKey();
}
else if (0 == columnEncryptionKey.Length)
else if (columnEncryptionKey.Length == 0)
{
throw SQL.EmptyColumnEncryptionKey();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e
throw SQL.NullEncryptedColumnEncryptionKey();
}

if (0 == encryptedColumnEncryptionKey.Length)
if (encryptedColumnEncryptionKey.Length == 0)
{
throw SQL.EmptyEncryptedColumnEncryptionKey();
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e
{
throw SQL.NullColumnEncryptionKey();
}
else if (0 == columnEncryptionKey.Length)
else if (columnEncryptionKey.Length == 0)
{
throw SQL.EmptyColumnEncryptionKey();
}
Expand Down
Loading