|
9 | 9 | using System.Diagnostics;
|
10 | 10 | using System.Diagnostics.CodeAnalysis;
|
11 | 11 | using System.Runtime.CompilerServices;
|
12 |
| -using System.Runtime.ConstrainedExecution; |
13 |
| -using System.Runtime.InteropServices; |
14 | 12 | using System.Runtime.Versioning;
|
15 | 13 | using System.Threading;
|
16 | 14 | using System.Threading.Tasks;
|
@@ -362,17 +360,17 @@ internal WaitHandle[] GetHandles(bool withCreate)
|
362 | 360 | }
|
363 | 361 | }
|
364 | 362 |
|
365 |
| - private const int MAX_Q_SIZE = (int)0x00100000; |
| 363 | + private const int MAX_Q_SIZE = 0x00100000; |
366 | 364 |
|
367 | 365 | // The order of these is important; we want the WaitAny call to be signaled
|
368 | 366 | // for a free object before a creation signal. Only the index first signaled
|
369 | 367 | // object is returned from the WaitAny call.
|
370 |
| - private const int SEMAPHORE_HANDLE = (int)0x0; |
371 |
| - private const int ERROR_HANDLE = (int)0x1; |
372 |
| - private const int CREATION_HANDLE = (int)0x2; |
373 |
| - private const int BOGUS_HANDLE = (int)0x3; |
| 368 | + private const int SEMAPHORE_HANDLE = 0x0; |
| 369 | + private const int ERROR_HANDLE = 0x1; |
| 370 | + private const int CREATION_HANDLE = 0x2; |
| 371 | + private const int BOGUS_HANDLE = 0x3; |
374 | 372 |
|
375 |
| - private const int WAIT_ABANDONED = (int)0x80; |
| 373 | + private const int WAIT_ABANDONED = 0x80; |
376 | 374 |
|
377 | 375 | private const int ERROR_WAIT_DEFAULT = 5 * 1000; // 5 seconds
|
378 | 376 |
|
@@ -511,7 +509,7 @@ private bool NeedToReplenish
|
511 | 509 | if (totalObjects < MinPoolSize)
|
512 | 510 | return true;
|
513 | 511 |
|
514 |
| - int freeObjects = (_stackNew.Count + _stackOld.Count); |
| 512 | + int freeObjects = _stackNew.Count + _stackOld.Count; |
515 | 513 | int waitingRequests = _waitCount;
|
516 | 514 | bool needToReplenish = (freeObjects < waitingRequests) || ((freeObjects == waitingRequests) && (totalObjects > 1));
|
517 | 515 |
|
@@ -606,7 +604,7 @@ private void CleanupCallback(object state)
|
606 | 604 |
|
607 | 605 | // Destroy free objects that put us above MinPoolSize from old stack.
|
608 | 606 | while (Count > MinPoolSize)
|
609 |
| - { |
| 607 | + { |
610 | 608 | // While above MinPoolSize...
|
611 | 609 | if (_waitHandles.PoolSemaphore.WaitOne(0, false))
|
612 | 610 | {
|
@@ -1429,17 +1427,17 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
|
1429 | 1427 | }
|
1430 | 1428 | break;
|
1431 | 1429 |
|
1432 |
| - case (WAIT_ABANDONED + SEMAPHORE_HANDLE): |
| 1430 | + case WAIT_ABANDONED + SEMAPHORE_HANDLE: |
1433 | 1431 | SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Semaphore handle abandonded.", ObjectID);
|
1434 | 1432 | Interlocked.Decrement(ref _waitCount);
|
1435 | 1433 | throw new AbandonedMutexException(SEMAPHORE_HANDLE, _waitHandles.PoolSemaphore);
|
1436 | 1434 |
|
1437 |
| - case (WAIT_ABANDONED + ERROR_HANDLE): |
| 1435 | + case WAIT_ABANDONED + ERROR_HANDLE: |
1438 | 1436 | SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Error handle abandonded.", ObjectID);
|
1439 | 1437 | Interlocked.Decrement(ref _waitCount);
|
1440 | 1438 | throw new AbandonedMutexException(ERROR_HANDLE, _waitHandles.ErrorEvent);
|
1441 | 1439 |
|
1442 |
| - case (WAIT_ABANDONED + CREATION_HANDLE): |
| 1440 | + case WAIT_ABANDONED + CREATION_HANDLE: |
1443 | 1441 | SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Creation handle abandoned.", ObjectID);
|
1444 | 1442 | Interlocked.Decrement(ref _waitCount);
|
1445 | 1443 | throw new AbandonedMutexException(CREATION_HANDLE, _waitHandles.CreationSemaphore);
|
@@ -1561,7 +1559,7 @@ private DbConnectionInternal GetFromGeneralPool()
|
1561 | 1559 | PerformanceCounters.NumberOfFreeConnections.Decrement();
|
1562 | 1560 | #endif
|
1563 | 1561 | }
|
1564 |
| - return (obj); |
| 1562 | + return obj; |
1565 | 1563 | }
|
1566 | 1564 |
|
1567 | 1565 | private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)
|
|
0 commit comments