Advertisement
Guest User

ConnectionPool

a guest
Nov 28th, 2014
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 114.00 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.EnterpriseServices;
  4. using System.Security.Principal;
  5. using System.Threading;
  6. using System.Transactions;
  7. namespace Oracle.DataAccess.Client
  8. {
  9.     internal class ConnectionPool
  10.     {
  11.         internal const int DEFAULT_STMT_CACHE_SIZE_WITH_SELF_TUNING = 30;
  12.         public const int WAIT_ABAONDONED = 128;
  13.         public const int WAIT_OBJECT_0 = 0;
  14.         public const int WAIT_TIMEOUT = 258;
  15.         public const int WAIT_FAILED = -1;
  16.         internal int m_agentKey = -1;
  17.         internal int m_poolId = -1;
  18.         internal int m_scsRecommendations = 30;
  19.         internal int m_stmtSamplesLimit;
  20.         public Stack m_connections;
  21.         public ResourcePool m_mtsConnections;
  22.         public OracleResourcePool m_oraResPool;
  23.         public IntPtr m_semAvaNumOfCons;
  24.         public Timer m_timer;
  25.         public OpoConCtx m_clonedCtx;
  26.         public Counter m_counter;
  27.         private bool m_skipDecrement;
  28.         public CPCtx m_cpCtx;
  29.         public int m_rlbGravCounter;
  30.         public float m_attemptedRequests;
  31.         public bool m_bSynchronizeStack;
  32.         public bool m_bClearPoolInProgress;
  33.         public int m_consFromAppToClear;
  34.         public bool m_bGridRac;
  35.         public EncryptedPasswords m_encryptedPasswords;
  36.         internal bool m_inactive;
  37.         private OraclePerfCounter[] m_perfCounterRefs;
  38.         internal object m_populationSyncObj;
  39.         public DateTime m_clearRequestTimeStamp;
  40.         private WindowsIdentity m_identity;
  41.         public ArrayList m_conList = ArrayList.Synchronized(new ArrayList());
  42.         internal bool HasValidConnections
  43.         {
  44.             get
  45.             {
  46.                 return this.m_conList.Count > 0;
  47.             }
  48.         }
  49.         public ConnectionPool(OpoConCtx opoConCtx, CPCtx cpCtx) : this(opoConCtx, cpCtx, null)
  50.         {
  51.         }
  52.         public unsafe ConnectionPool(OpoConCtx opoConCtx, CPCtx cpCtx, WindowsIdentity identity)
  53.         {
  54.             try
  55.             {
  56.                 this.m_populationSyncObj = new object();
  57.                 this.m_poolId = opoConCtx.conString.GetHashCode();
  58.                 if (opoConCtx.m_bSelfTuning)
  59.                 {
  60.                     this.m_stmtSamplesLimit = 1000;
  61.                     OracleTuningAgent.Register(opoConCtx.conString, opoConCtx.poolName, this.m_poolId, new OracleTuningAgent.UpdateRecommendations(this.UpdateAgentRecommendations), new OracleTuningAgent.IncrementStmtSamplesLimit(this.IncrementStmtSamplesLimit), out this.m_agentKey);
  62.                     if (-1 == this.m_agentKey)
  63.                     {
  64.                         opoConCtx.m_bSelfTuning = false;
  65.                     }
  66.                 }
  67.             }
  68.             catch (Exception ex)
  69.             {
  70.                 if (OraTrace.m_TraceLevel != 0u)
  71.                 {
  72.                     OraTrace.Trace(64u, new string[]
  73.                     {
  74.                         string.Concat(new string[]
  75.                         {
  76.                             "(ERROR) ConnectionPool::ConnectionPool(): Pool ",
  77.                             opoConCtx.conString,
  78.                             "; Exception: ",
  79.                             ex.ToString(),
  80.                             " \n"
  81.                         })
  82.                     });
  83.                 }
  84.             }
  85.             this.m_scsRecommendations = opoConCtx.pOpoConValCtx->StmtCacheSize;
  86.             if (OraTrace.m_PerformanceCounters != PerfCounterLevel.None)
  87.             {
  88.                 this.m_perfCounterRefs = new OraclePerfCounter[12];
  89.             }
  90.             this.m_connections = Stack.Synchronized(new Stack(opoConCtx.minPoolSize));
  91.             this.m_cpCtx = cpCtx;
  92.             if (Environment.OSVersion.Version.Major <= 4)
  93.             {
  94.                 opoConCtx.pOpoConValCtx->Enlist = 0;
  95.             }
  96.             else
  97.             {
  98.                 this.m_oraResPool = new OracleResourcePool(new OracleResourcePool.TransactionEndDelegate(this.TransactionEnd));
  99.                 this.m_mtsConnections = new ResourcePool(new ResourcePool.TransactionEndDelegate(this.TransactionEnd));
  100.             }
  101.             try
  102.             {
  103.                 this.m_semAvaNumOfCons = OpsCon.CreateSemaphore(IntPtr.Zero, 0, opoConCtx.maxPoolSize, "");
  104.             }
  105.             catch (Exception ex2)
  106.             {
  107.                 if (OraTrace.m_TraceLevel != 0u)
  108.                 {
  109.                     OraTrace.TraceExceptionInfo(ex2);
  110.                 }
  111.                 throw;
  112.             }
  113.             this.m_identity = null;
  114.             try
  115.             {
  116.                 if (opoConCtx.pOpoConValCtx->OSAuthent == 1 || opoConCtx.pOpoConValCtx->OSAuthent == 2)
  117.                 {
  118.                     if (identity != null)
  119.                     {
  120.                         this.m_identity = identity;
  121.                     }
  122.                     else
  123.                     {
  124.                         this.m_identity = WindowsIdentity.GetCurrent();
  125.                     }
  126.                 }
  127.             }
  128.             catch (Exception ex3)
  129.             {
  130.                 if (OraTrace.m_TraceLevel != 0u)    
  131.                 {
  132.                     OraTrace.Trace(2u, new string[]
  133.                     {
  134.                         string.Concat(new string[]
  135.                         {
  136.                             " (POOL) (ERROR) ConnectionPool::ConnectionPool(): Pool: ",
  137.                             opoConCtx.poolName,
  138.                             "; Exception: ",
  139.                             ex3.ToString(),
  140.                             " \n"
  141.                         })
  142.                     });
  143.                 }
  144.             }
  145.             this.m_clonedCtx = (OpoConCtx)opoConCtx.Clone();
  146.             this.m_clonedCtx.pool = this;
  147.             opoConCtx.pool = this;
  148.             this.m_encryptedPasswords = new EncryptedPasswords(opoConCtx);
  149.             this.m_clonedCtx.opoConRefCtx.password = null;
  150.             this.m_clonedCtx.opoConRefCtx.proxyPassword = null;
  151.             this.m_bGridRac = this.m_clonedCtx.bGridRac;
  152.             this.m_clonedCtx.pOpoConValCtx->Pooling = (*opoConCtx.pOpoConValCtx).Pooling;
  153.             this.m_clonedCtx.pOpoConValCtx->DBAPrivilege = (*opoConCtx.pOpoConValCtx).DBAPrivilege;
  154.             this.m_clonedCtx.pOpoConValCtx->SetIntAndExtName = (*opoConCtx.pOpoConValCtx).SetIntAndExtName;
  155.             if (this.m_cpCtx == null)
  156.             {
  157.                 this.m_timer = new Timer(new TimerCallback(this.RegulateNumOfConsThreadFunc), null, opoConCtx.poolRegulator * 1000, opoConCtx.poolRegulator * 1000);
  158.             }
  159.             this.m_counter = new Counter(false);
  160.             this.m_skipDecrement = true;
  161.             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  162.             {
  163.                 ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  164.             }
  165.         }
  166.         ~ConnectionPool()
  167.         {
  168.             this.Dispose();
  169.         }
  170.         private void Dispose()
  171.         {
  172.             try
  173.             {
  174.                 if (this.m_agentKey != -1)
  175.                 {
  176.                     OracleTuningAgent.Unregister(this.m_agentKey);
  177.                 }
  178.             }
  179.             catch (Exception ex)
  180.             {
  181.                 if (OraTrace.m_TraceLevel != 0u)
  182.                 {
  183.                     OraTrace.Trace(64u, new string[]
  184.                     {
  185.                         string.Concat(new object[]
  186.                         {
  187.                             "(ERROR) ConnectionPool::Dispose(): Pool Id: ",
  188.                             this.m_poolId,
  189.                             "; Exception: ",
  190.                             ex.ToString(),
  191.                             " \n"
  192.                         })
  193.                     });
  194.                 }
  195.             }
  196.             try
  197.             {
  198.                 if (this.m_semAvaNumOfCons != IntPtr.Zero)
  199.                 {
  200.                     try
  201.                     {
  202.                         OpsCon.CloseHandle(this.m_semAvaNumOfCons);
  203.                     }
  204.                     catch (Exception ex2)
  205.                     {
  206.                         if (OraTrace.m_TraceLevel != 0u)
  207.                         {
  208.                             OraTrace.TraceExceptionInfo(ex2);
  209.                         }
  210.                     }
  211.                     this.m_semAvaNumOfCons = IntPtr.Zero;
  212.                 }
  213.                 this.m_encryptedPasswords.Dispose();
  214.                 if (this.m_clonedCtx != null && this.m_clonedCtx.pOpoConValCtx != null)
  215.                 {
  216.                     try
  217.                     {
  218.                         OpsCon.FreeValCtx(ref this.m_clonedCtx.pOpoConValCtx);
  219.                     }
  220.                     catch (Exception ex3)
  221.                     {
  222.                         if (OraTrace.m_TraceLevel != 0u)
  223.                         {
  224.                             OraTrace.TraceExceptionInfo(ex3);
  225.                         }
  226.                     }
  227.                 }
  228.                 int count = this.m_connections.Count;
  229.                 while (this.m_connections.Count > 0)
  230.                 {
  231.                     PooledConCtx pooledConCtx = null;
  232.                     bool flag = this.m_cpCtx != null;
  233.                     if (flag)
  234.                     {
  235.                         Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
  236.                     }
  237.                     if (this.m_bSynchronizeStack)
  238.                     {
  239.                         lock (this.m_connections.SyncRoot)
  240.                         {
  241.                             pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  242.                             goto IL_181;
  243.                         }
  244.                         goto IL_16F;
  245.                     }
  246.                     goto IL_16F;
  247.                     IL_181:
  248.                     pooledConCtx.m_conPooler = null;
  249.                     pooledConCtx.m_udtDescPoolerByName = null;
  250.                     pooledConCtx.m_udtDescPoolerByTDO = null;
  251.                     try
  252.                     {
  253.                         if (pooledConCtx.m_fetchArrayPooler != null)
  254.                         {
  255.                             pooledConCtx.m_fetchArrayPooler.Dispose();
  256.                             pooledConCtx.m_fetchArrayPooler = null;
  257.                         }
  258.                         if (!pooledConCtx.m_bOpsConCtxDisposed)
  259.                         {
  260.                             lock (pooledConCtx.m_syncObject)
  261.                             {
  262.                                 if (!pooledConCtx.m_bOpsConCtxDisposed)
  263.                                 {
  264.                                     if (this.m_clonedCtx.gridCR == 1)
  265.                                     {
  266.                                         this.m_conList.Remove(pooledConCtx);
  267.                                         if (OraTrace.m_TraceLevel != 0u)
  268.                                         {
  269.                                             OraTrace.Trace(16u, new string[]
  270.                                             {
  271.                                                 string.Concat(new object[]
  272.                                                 {
  273.                                                     " (ConnectionPool's Dispose) Pool Id = ",
  274.                                                     this.m_poolId,
  275.                                                     " Removed PooledConCtx= ",
  276.                                                     pooledConCtx.GetHashCode(),
  277.                                                     "\n"
  278.                                                 })
  279.                                             });
  280.                                         }
  281.                                     }
  282.                                     OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  283.                                     pooledConCtx.m_bOpsConCtxDisposed = true;
  284.                                 }
  285.                             }
  286.                         }
  287.                     }
  288.                     catch (Exception ex4)
  289.                     {
  290.                         if (OraTrace.m_TraceLevel != 0u)
  291.                         {
  292.                             OraTrace.TraceExceptionInfo(ex4);
  293.                         }
  294.                     }
  295.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  296.                     {
  297.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
  298.                         continue;
  299.                     }
  300.                     continue;
  301.                     IL_16F:
  302.                     pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  303.                     goto IL_181;
  304.                 }
  305.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  306.                 {
  307.                     ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfFreeConnections, -1 * count, this.m_clonedCtx);
  308.                 }
  309.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  310.                 {
  311.                     ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfPooledConnections, -1 * count, this.m_clonedCtx);
  312.                 }
  313.             }
  314.             catch
  315.             {
  316.             }
  317.             if (this.m_inactive)
  318.             {
  319.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  320.                 {
  321.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  322.                 }
  323.             }
  324.             else
  325.             {
  326.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  327.                 {
  328.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  329.                 }
  330.             }
  331.             GC.SuppressFinalize(this);
  332.         }
  333.         public unsafe void PopulatePool(object state)
  334.         {
  335.             if (OraTrace.m_TraceLevel != 0u)
  336.             {
  337.                 OraTrace.Trace(2u, new string[]
  338.                 {
  339.                     " (POOL) (ENTRY) ConnectionPool::PopulatePool(): Pool (id: " + this.m_clonedCtx.conString.GetHashCode() + ");\n"
  340.                 });
  341.             }
  342.             int num = 0;
  343.             int num2 = (int)state;
  344.             int num3 = 0;
  345.             int num4 = 0;
  346.             WindowsImpersonationContext windowsImpersonationContext = null;
  347.             try
  348.             {
  349.                 if (OraTrace.m_CPThreadPrioritization == 1)
  350.                 {
  351.                     Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
  352.                 }
  353.             }
  354.             catch
  355.             {
  356.                 OraTrace.m_CPThreadPrioritization = 0;
  357.             }
  358.             try
  359.             {
  360.                 if (this.m_identity != null)
  361.                 {
  362.                     try
  363.                     {
  364.                         if (WindowsIdentity.GetCurrent() != this.m_identity)
  365.                         {
  366.                             windowsImpersonationContext = this.m_identity.Impersonate();
  367.                         }
  368.                     }
  369.                     catch (Exception ex)
  370.                     {
  371.                         windowsImpersonationContext = null;
  372.                         if (OraTrace.m_TraceLevel != 0u)
  373.                         {
  374.                             OraTrace.Trace(2u, new string[]
  375.                             {
  376.                                 string.Concat(new object[]
  377.                                 {
  378.                                     " (POOL) (ERROR) ConnectionPool::PopulatePool(): Pool (id: ",
  379.                                     this.m_clonedCtx.conString.GetHashCode(),
  380.                                     "); Exception: ",
  381.                                     ex.ToString(),
  382.                                     " \n"
  383.                                 })
  384.                             });
  385.                         }
  386.                         throw;
  387.                     }
  388.                 }
  389.                 ConnectionPool connectionPool = this;
  390.                 int num5 = 0;
  391.                 if ((this.m_bGridRac && this.m_cpCtx.m_counter.total < this.m_clonedCtx.maxPoolSize) || (!this.m_bGridRac && this.m_counter.total < this.m_clonedCtx.maxPoolSize))
  392.                 {
  393.                     lock (this.m_populationSyncObj)
  394.                     {
  395.                         for (int i = 0; i < num2; i++)
  396.                         {
  397.                             if (this.m_bGridRac)
  398.                             {
  399.                                 if (this.m_cpCtx.m_counter.total >= this.m_clonedCtx.maxPoolSize)
  400.                                 {
  401.                                     break;
  402.                                 }
  403.                             }
  404.                             else
  405.                             {
  406.                                 if (this.m_counter.total >= this.m_clonedCtx.maxPoolSize)
  407.                                 {
  408.                                     break;
  409.                                 }
  410.                             }
  411.                             OpoConCtx opoConCtx = (OpoConCtx)this.m_clonedCtx.Clone();
  412.                             try
  413.                             {
  414.                                 if (this.m_encryptedPasswords.m_encryptedPwd != null)
  415.                                 {
  416.                                     opoConCtx.opoConRefCtx.password = this.m_encryptedPasswords.m_encryptedPwd.Password;
  417.                                 }
  418.                                 else
  419.                                 {
  420.                                     opoConCtx.opoConRefCtx.password = "";
  421.                                 }
  422.                                 if (this.m_encryptedPasswords.m_encryptedPxyPwd != null)
  423.                                 {
  424.                                     opoConCtx.opoConRefCtx.proxyPassword = this.m_encryptedPasswords.m_encryptedPxyPwd.Password;
  425.                                 }
  426.                                 else
  427.                                 {
  428.                                     opoConCtx.opoConRefCtx.proxyPassword = "";
  429.                                 }
  430.                                 if (opoConCtx.m_bSelfTuning)
  431.                                 {
  432.                                     opoConCtx.pOpoConValCtx->StmtCacheSize = this.m_scsRecommendations;
  433.                                     if (opoConCtx.pOpoConValCtx->StmtCacheSize > OraTrace.MaxStatementCacheSize)
  434.                                     {
  435.                                         opoConCtx.pOpoConValCtx->StmtCacheSize = OraTrace.MaxStatementCacheSize;
  436.                                     }
  437.                                 }
  438.                                 num = OpsCon.Open(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, ref opoConCtx.opoConRefCtx);
  439.                                 if (num == 0 && (OraTrace.m_PerformanceCounters & PerfCounterLevel.HardConnectsPerSecond) == PerfCounterLevel.HardConnectsPerSecond)
  440.                                 {
  441.                                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardConnectsPerSecond, opoConCtx);
  442.                                 }
  443.                                 if (opoConCtx.metaPool == 1)
  444.                                 {
  445.                                     if (opoConCtx.m_bSelfTuning)
  446.                                     {
  447.                                         int maxElemsInPool = (opoConCtx.pOpoConValCtx->StmtCacheSize > ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON) ? opoConCtx.pOpoConValCtx->StmtCacheSize : ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON;
  448.                                         opoConCtx.m_conPooler = new ConPooler(maxElemsInPool);
  449.                                         opoConCtx.m_udtDescPoolerByName = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON);
  450.                                     }
  451.                                     else
  452.                                     {
  453.                                         opoConCtx.m_conPooler = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
  454.                                         opoConCtx.m_udtDescPoolerByName = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
  455.                                     }
  456.                                 }
  457.                                 if (opoConCtx.m_bSelfTuning)
  458.                                 {
  459.                                     opoConCtx.m_udtDescPoolerByTDO = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON);
  460.                                 }
  461.                                 else
  462.                                 {
  463.                                     opoConCtx.m_udtDescPoolerByTDO = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
  464.                                 }
  465.                                 if (num == 0 && this.m_clonedCtx.opoConRefCtx.dbName == null)
  466.                                 {
  467.                                     this.m_clonedCtx.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
  468.                                     this.m_clonedCtx.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
  469.                                     this.m_clonedCtx.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
  470.                                     this.m_clonedCtx.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
  471.                                 }
  472.                                 if (num == 0 && (num = ConnectionDispenser.RegisterCallbacks(opoConCtx)) != 0)
  473.                                 {
  474.                                     if (opoConCtx.m_fetchArrayPooler != null)
  475.                                     {
  476.                                         opoConCtx.m_fetchArrayPooler.Dispose();
  477.                                         opoConCtx.m_fetchArrayPooler = null;
  478.                                     }
  479.                                     OpoConValCtx* ptr = null;
  480.                                     try
  481.                                     {
  482.                                         if (!opoConCtx.m_bOpsConCtxDisposed)
  483.                                         {
  484.                                             lock (opoConCtx.m_syncObject)
  485.                                             {
  486.                                                 if (!opoConCtx.m_bOpsConCtxDisposed)
  487.                                                 {
  488.                                                     if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  489.                                                     {
  490.                                                         opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  491.                                                         if (OraTrace.m_TraceLevel != 0u)
  492.                                                         {
  493.                                                             OraTrace.Trace(16u, new string[]
  494.                                                             {
  495.                                                                 string.Concat(new object[]
  496.                                                                 {
  497.                                                                     " (PopulatePool) Pool Id = ",
  498.                                                                     opoConCtx.pool.m_poolId,
  499.                                                                     " Removed PooledConCtx= ",
  500.                                                                     opoConCtx.pooledConCtx.GetHashCode(),
  501.                                                                     "\n"
  502.                                                                 })
  503.                                                             });
  504.                                                         }
  505.                                                     }
  506.                                                     OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  507.                                                     OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
  508.                                                     opoConCtx.m_bOpsConCtxDisposed = true;
  509.                                                     if (opoConCtx.pooledConCtx != null)
  510.                                                     {
  511.                                                         opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  512.                                                     }
  513.                                                 }
  514.                                             }
  515.                                         }
  516.                                     }
  517.                                     catch (Exception ex2)
  518.                                     {
  519.                                         if (OraTrace.m_TraceLevel != 0u)
  520.                                         {
  521.                                             OraTrace.TraceExceptionInfo(ex2);
  522.                                         }
  523.                                     }
  524.                                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  525.                                     {
  526.                                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  527.                                     }
  528.                                 }
  529.                                 if (num != 0)
  530.                                 {
  531.                                     if (opoConCtx.validateCon == 1)
  532.                                     {
  533.                                         goto IL_9F3;
  534.                                     }
  535.                                     lock (this.m_bGridRac ? this.m_cpCtx.m_counter : this.m_counter)
  536.                                     {
  537.                                         if ((this.m_bGridRac && this.m_cpCtx.m_counter.threadWait <= this.m_cpCtx.totalAvaliableConnections) || (!this.m_bGridRac && this.m_counter.threadWait <= this.m_counter.totalAvailable))
  538.                                         {
  539.                                             goto IL_9F3;
  540.                                         }
  541.                                     }
  542.                                 }
  543.                                 opoConCtx.creationTime = DateTime.Now;
  544.                                 this.m_skipDecrement = true;
  545.                                 if (this.m_cpCtx != null)
  546.                                 {
  547.                                     this.m_cpCtx.m_cpCtxSkipDecrement = true;
  548.                                 }
  549.                                 bool flag4 = false;
  550.                                 if (opoConCtx.pOpoConValCtx->SessionBegin == 1)
  551.                                 {
  552.                                     flag4 = true;
  553.                                 }
  554.                                 int num6;
  555.                                 if (this.m_bGridRac)
  556.                                 {
  557.                                     connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  558.                                     if (connectionPool == null)
  559.                                     {
  560.                                         lock (this.m_cpCtx.htInstToCp.SyncRoot)
  561.                                         {
  562.                                             connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  563.                                             if (connectionPool == null)
  564.                                             {
  565.                                                 connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
  566.                                                 this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
  567.                                                 if (OraTrace.m_TraceLevel != 0u)
  568.                                                 {
  569.                                                     OraTrace.Trace(2u, new string[]
  570.                                                     {
  571.                                                         string.Concat(new object[]
  572.                                                         {
  573.                                                             " (POOL)  New CP created (CP id: ",
  574.                                                             connectionPool.GetHashCode(),
  575.                                                             "; CPCtx id: ",
  576.                                                             this.m_cpCtx.GetHashCode(),
  577.                                                             ") for: [Instance=",
  578.                                                             opoConCtx.opoConRefCtx.instanceName,
  579.                                                             "]\n"
  580.                                                         })
  581.                                                     });
  582.                                                     OraTrace.Trace(2u, new string[]
  583.                                                     {
  584.                                                         string.Concat(new object[]
  585.                                                         {
  586.                                                             " (POOL)  Num of Inst CPs in (CPCtx id: ",
  587.                                                             this.m_cpCtx.GetHashCode(),
  588.                                                             ") : ",
  589.                                                             this.m_cpCtx.htInstToCp.Count,
  590.                                                             "\n"
  591.                                                         })
  592.                                                     });
  593.                                                 }
  594.                                             }
  595.                                         }
  596.                                     }
  597.                                     if (this.m_clonedCtx.gridCR == 1)
  598.                                     {
  599.                                         if (opoConCtx.pooledConCtx == null)
  600.                                         {
  601.                                             opoConCtx.pooledConCtx = PooledConCtx.CopyOpoConCtx(opoConCtx);
  602.                                         }
  603.                                         if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx) && opoConCtx.opsConCtx != IntPtr.Zero)
  604.                                         {
  605.                                             connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
  606.                                             if (OraTrace.m_TraceLevel != 0u)
  607.                                             {
  608.                                                 OraTrace.Trace(16u, new string[]
  609.                                                 {
  610.                                                     string.Concat(new object[]
  611.                                                     {
  612.                                                         " (PopulatePool) Pool Id = ",
  613.                                                         connectionPool.m_poolId,
  614.                                                         " Added PooledConCtx= ",
  615.                                                         opoConCtx.pooledConCtx.GetHashCode(),
  616.                                                         "\n"
  617.                                                     })
  618.                                                 });
  619.                                             }
  620.                                         }
  621.                                     }
  622.                                     num5++;
  623.                                     if (this.m_bSynchronizeStack)
  624.                                     {
  625.                                         lock (this.m_connections)
  626.                                         {
  627.                                             num6 = connectionPool.PutConnection(ref opoConCtx, true, false, true, 0, true, true);
  628.                                             goto IL_980;
  629.                                         }
  630.                                     }
  631.                                     num6 = connectionPool.PutConnection(ref opoConCtx, true, false, true, 0, true, true);
  632.                                 }
  633.                                 else
  634.                                 {
  635.                                     connectionPool = this;
  636.                                     if (this.m_bSynchronizeStack)
  637.                                     {
  638.                                         lock (this.m_connections)
  639.                                         {
  640.                                             num6 = this.PutConnection(ref opoConCtx, true, false, false, 0, true, true);
  641.                                             goto IL_980;
  642.                                         }
  643.                                     }
  644.                                     num6 = this.PutConnection(ref opoConCtx, true, false, false, 0, true, true);
  645.                                 }
  646.                                 IL_980:
  647.                                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.SoftDisconnectsPerSecond) == PerfCounterLevel.SoftDisconnectsPerSecond)
  648.                                 {
  649.                                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.SoftDisconnectsPerSecond, opoConCtx);
  650.                                 }
  651.                                 if (flag4 && num == 0 && num6 == 0)
  652.                                 {
  653.                                     connectionPool.UpdateTotalCount(1, false);
  654.                                     if (connectionPool == this)
  655.                                     {
  656.                                         num3++;
  657.                                     }
  658.                                     else
  659.                                     {
  660.                                         connectionPool.m_counter.UpdatePotentialTotalCount(1);
  661.                                     }
  662.                                     num4++;
  663.                                 }
  664.                             }
  665.                             catch (Exception ex3)
  666.                             {
  667.                                 if (OraTrace.m_TraceLevel != 0u)
  668.                                 {
  669.                                     OraTrace.TraceExceptionInfo(ex3);
  670.                                 }
  671.                             }
  672.                             finally
  673.                             {
  674.                                 opoConCtx.opoConRefCtx.password = null;
  675.                                 opoConCtx.opoConRefCtx.proxyPassword = null;
  676.                             }
  677.                             IL_9F3:;
  678.                         }
  679.                     }
  680.                 }
  681.                 if (this.m_bGridRac && num5 - num4 > 0)
  682.                 {
  683.                     this.m_cpCtx.m_counter.UpdatePotentialTotalCount(num4 - num5);
  684.                 }
  685.                 if (num5 - num3 > 0)
  686.                 {
  687.                     this.m_counter.UpdatePotentialTotalCount(num3 - num5);
  688.                 }
  689.             }
  690.             finally
  691.             {
  692.                 if (windowsImpersonationContext != null)
  693.                 {
  694.                     try
  695.                     {
  696.                         windowsImpersonationContext.Undo();
  697.                     }
  698.                     catch (Exception ex4)
  699.                     {
  700.                         if (OraTrace.m_TraceLevel != 0u)
  701.                         {
  702.                             OraTrace.Trace(2u, new string[]
  703.                             {
  704.                                 string.Concat(new object[]
  705.                                 {
  706.                                     " (POOL) (ERROR) ConnectionPool::PopulatePool(): Pool (id: ",
  707.                                     this.m_clonedCtx.conString.GetHashCode(),
  708.                                     "); Exception: ",
  709.                                     ex4.ToString(),
  710.                                     " \n"
  711.                                 })
  712.                             });
  713.                         }
  714.                     }
  715.                     windowsImpersonationContext = null;
  716.                 }
  717.             }
  718.             if (OraTrace.m_TraceLevel != 0u)
  719.             {
  720.                 OraTrace.Trace(2u, new string[]
  721.                 {
  722.                     " (POOL) (EXIT) ConnectionPool::PopulatePool(): Pool (id: " + this.m_clonedCtx.conString.GetHashCode() + ");\n"
  723.                 });
  724.             }
  725.         }
  726.         public static void PerformanceCounterIncrement(OraclePerfParams.CounterIndex iCounter, OpoConCtx opoConCtx)
  727.         {
  728.             if (opoConCtx.pool == null || (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null))
  729.             {
  730.                 OraclePerfCounter oraclePerfCounter = OraclePerfCounterCollection.Increment(iCounter, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
  731.                 if (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null)
  732.                 {
  733.                     opoConCtx.pool.m_perfCounterRefs[(int)iCounter] = oraclePerfCounter;
  734.                     return;
  735.                 }
  736.             }
  737.             else
  738.             {
  739.                 opoConCtx.pool.m_perfCounterRefs[(int)iCounter].Increment();
  740.             }
  741.         }
  742.         public static void PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex iCounter, int value, OpoConCtx opoConCtx)
  743.         {
  744.             if (opoConCtx.pool == null || (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null))
  745.             {
  746.                 OraclePerfCounter oraclePerfCounter = OraclePerfCounterCollection.IncrementBy(iCounter, value, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
  747.                 if (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null)
  748.                 {
  749.                     opoConCtx.pool.m_perfCounterRefs[(int)iCounter] = oraclePerfCounter;
  750.                     return;
  751.                 }
  752.             }
  753.             else
  754.             {
  755.                 opoConCtx.pool.m_perfCounterRefs[(int)iCounter].IncrementBy(value);
  756.             }
  757.         }
  758.         public static void PerformanceCounterDecrement(OraclePerfParams.CounterIndex iCounter, OpoConCtx opoConCtx)
  759.         {
  760.             if (opoConCtx.pool == null)
  761.             {
  762.                 OraclePerfCounterCollection.Decrement(iCounter, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
  763.                 return;
  764.             }
  765.             opoConCtx.pool.m_perfCounterRefs[(int)iCounter].Decrement();
  766.         }
  767.         internal static string GetInstanceName(OpoConCtx opoConCtx)
  768.         {
  769.             string result = null;
  770.             if (opoConCtx.gridCR == 1 || opoConCtx.gridRLB == 1)
  771.             {
  772.                 result = opoConCtx.opoConRefCtx.instanceName;
  773.             }
  774.             return result;
  775.         }
  776.         public void UpdateTotalCount(int val, bool bForPotential)
  777.         {
  778.             if (this.m_clonedCtx.bGridRac)
  779.             {
  780.                 this.m_cpCtx.m_counter.UpdateTotalCount(this, val, bForPotential);
  781.             }
  782.             this.m_counter.UpdateTotalCount(this, val, bForPotential);
  783.         }
  784.         public void UpdatePotentialTotalCount(int val)
  785.         {
  786.             if (this.m_clonedCtx.bGridRac)
  787.             {
  788.                 this.m_cpCtx.m_counter.UpdatePotentialTotalCount(val);
  789.             }
  790.             this.m_counter.UpdatePotentialTotalCount(val);
  791.         }
  792.         public void UpdateThreadWaitCount(int val)
  793.         {
  794.             this.m_counter.UpdateThreadWaitCount(this, val);
  795.         }
  796.         public void RegulateNumOfConsThreadFunc(object state)
  797.         {
  798.             this.RegulateNumOfCons(state);
  799.         }
  800.         public void GetDisposalInfo(int totDecrCount, ref ConnectionPool[] conPool, ref int[] consToClose)
  801.         {
  802.             conPool = null;
  803.             consToClose = null;
  804.             int[] array = null;
  805.             int num = 0;
  806.             int num2 = 2147483647;
  807.             int num3 = 0;
  808.             if (this.m_cpCtx != null && this.m_cpCtx.htInstToCp != null)
  809.             {
  810.                 num3 = this.m_cpCtx.htInstToCp.Count;
  811.             }
  812.             if (this.m_cpCtx != null && this.m_cpCtx.htInstToCp != null && num3 > 0)
  813.             {
  814.                 int num4 = this.m_cpCtx.m_random.Next(0, num3);
  815.                 lock (this.m_cpCtx.htInstToCp)
  816.                 {
  817.                     num3 = this.m_cpCtx.htInstToCp.Count;
  818.                     if (num3 > 0)
  819.                     {
  820.                         IDictionaryEnumerator enumerator = this.m_cpCtx.htInstToCp.GetEnumerator();
  821.                         conPool = new ConnectionPool[num3];
  822.                         array = new int[num3];
  823.                         while (enumerator.MoveNext())
  824.                         {
  825.                             conPool[num4] = (ConnectionPool)enumerator.Value;
  826.                             array[num4] = conPool[num4].m_connections.Count;
  827.                             num += array[num4];
  828.                             if (array[num4] < num2)
  829.                             {
  830.                                 num2 = array[num4];
  831.                             }
  832.                             num4 = (num4 + 1) % num3;
  833.                         }
  834.                     }
  835.                 }
  836.                 if (num <= totDecrCount)
  837.                 {
  838.                     consToClose = array;
  839.                     return;
  840.                 }
  841.                 int num5 = 0;
  842.                 consToClose = new int[num3];
  843.                 if (num2 * num3 > totDecrCount)
  844.                 {
  845.                     num2 = totDecrCount / num3;
  846.                     for (int i = 0; i < num3; i++)
  847.                     {
  848.                         consToClose[i] = num2;
  849.                         array[i] -= num2;
  850.                         num5 += num2;
  851.                     }
  852.                 }
  853.                 for (int i = 0; i < num3 * totDecrCount; i++)
  854.                 {
  855.                     num4 = i % num3;
  856.                     if (array[num4] > 0)
  857.                     {
  858.                         consToClose[num4]++;
  859.                         array[num4]--;
  860.                         num5++;
  861.                         if (num5 >= totDecrCount)
  862.                         {
  863.                             return;
  864.                         }
  865.                     }
  866.                 }
  867.             }
  868.         }
  869.         public unsafe int RegulateNumOfCons(object state)
  870.         {
  871.             bool flag = false;
  872.             int num = 0;
  873.             bool flag2 = state == null;
  874.             bool bGridRac = this.m_clonedCtx.bGridRac;
  875.             try
  876.             {
  877.                 if (this.m_cpCtx != null)
  878.                 {
  879.                     Monitor.Enter(this.m_cpCtx);
  880.                 }
  881.                 int num2;
  882.                 int total;
  883.                 int potentialTotal;
  884.                 int num3;
  885.                 bool flag3;
  886.                 if (bGridRac)
  887.                 {
  888.                     num2 = this.m_cpCtx.totalAvaliableConnections;
  889.                     total = this.m_cpCtx.m_counter.total;
  890.                     potentialTotal = this.m_cpCtx.m_counter.potentialTotal;
  891.                     num3 = this.m_clonedCtx.origMinPoolSize;
  892.                     flag3 = this.m_cpCtx.m_cpCtxSkipDecrement;
  893.                 }
  894.                 else
  895.                 {
  896.                     num2 = this.m_connections.Count;
  897.                     total = this.m_counter.total;
  898.                     potentialTotal = this.m_counter.potentialTotal;
  899.                     num3 = this.m_clonedCtx.minPoolSize;
  900.                     flag3 = this.m_skipDecrement;
  901.                 }
  902.                 if (num2 > 0 && (total > num3 || this.m_rlbGravCounter > 0 || (state != null && (int)state == -1)) && (!flag3 || state != null))
  903.                 {
  904.                     int num4 = 0;
  905.                     if (state == null)
  906.                     {
  907.                         if (num2 < this.m_clonedCtx.poolDecSize)
  908.                         {
  909.                             num4 = num2;
  910.                         }
  911.                         else
  912.                         {
  913.                             num4 = this.m_clonedCtx.poolDecSize;
  914.                         }
  915.                         if (total - num4 < num3)
  916.                         {
  917.                             num4 = total - num3;
  918.                         }
  919.                     }
  920.                     else
  921.                     {
  922.                         bool flag4 = false;
  923.                         try
  924.                         {
  925.                             Monitor.Enter(this, ref flag4);
  926.                             if ((int)state == -1)
  927.                             {
  928.                                 num4 = this.m_clonedCtx.maxPoolSize;
  929.                             }
  930.                             else
  931.                             {
  932.                                 if (this.m_rlbGravCounter <= 0)
  933.                                 {
  934.                                     num4 = Math.Min((int)state, total - num3);
  935.                                 }
  936.                                 else
  937.                                 {
  938.                                     if (this.m_rlbGravCounter > 0)
  939.                                     {
  940.                                         num4 = this.m_rlbGravCounter;
  941.                                         this.m_rlbGravCounter = 0;
  942.                                     }
  943.                                 }
  944.                             }
  945.                         }
  946.                         finally
  947.                         {
  948.                             if (flag4)
  949.                             {
  950.                                 Monitor.Exit(this);
  951.                             }
  952.                         }
  953.                     }
  954.                     bool flag5 = this.m_cpCtx != null && this.m_cpCtx.m_rlbCtx.RLBMetricsList != null && this.m_cpCtx.m_rlbCtx.RLBMetricsList.Count != 0;
  955.                     if (bGridRac && flag2 && !flag5)
  956.                     {
  957.                         ConnectionPool[] array = null;
  958.                         int[] array2 = null;
  959.                         this.GetDisposalInfo(num4, ref array, ref array2);
  960.                         if (array != null)
  961.                         {
  962.                             for (int i = 0; i < array.Length; i++)
  963.                             {
  964.                                 array[i].RegulateNumOfCons(array2[i]);
  965.                                 array[i] = null;
  966.                             }
  967.                         }
  968.                     }
  969.                     else
  970.                     {
  971.                         if (!bGridRac || !flag2 || !flag5)
  972.                         {
  973.                             for (int j = 0; j < num4; j++)
  974.                             {
  975.                                 PooledConCtx pooledConCtx = null;
  976.                                 try
  977.                                 {
  978.                                     int num5 = 0;
  979.                                     if (bGridRac && this.m_cpCtx != null)
  980.                                     {
  981.                                         num5 = OpsCon.WaitForSingleObject(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 0);
  982.                                     }
  983.                                     int num6 = 0;
  984.                                     if (num5 == 0)
  985.                                     {
  986.                                         num6 = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, 0);
  987.                                     }
  988.                                     if (num6 == 0 && num5 == 0)
  989.                                     {
  990.                                         if (bGridRac && this.m_cpCtx != null)
  991.                                         {
  992.                                             Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
  993.                                         }
  994.                                         Interlocked.Decrement(ref this.m_counter.totalAvailable);
  995.                                         if (this.m_bSynchronizeStack)
  996.                                         {
  997.                                             lock (this.m_connections.SyncRoot)
  998.                                             {
  999.                                                 pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  1000.                                                 goto IL_304;
  1001.                                             }
  1002.                                         }
  1003.                                         pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  1004.                                         IL_304:
  1005.                                         if (pooledConCtx != null)
  1006.                                         {
  1007.                                             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  1008.                                             {
  1009.                                                 ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
  1010.                                             }
  1011.                                             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  1012.                                             {
  1013.                                                 ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
  1014.                                             }
  1015.                                         }
  1016.                                         if (pooledConCtx.pOpoConValCtx->bTAFEnabled == 1)
  1017.                                         {
  1018.                                             ConnectionPool connectionPool = this;
  1019.                                             string instanceName = pooledConCtx.opoConRefCtx.instanceName;
  1020.                                             OpsCon.GetAttributes(pooledConCtx.opsConCtx, pooledConCtx.opsErrCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  1021.                                             if (instanceName != pooledConCtx.opoConRefCtx.instanceName)
  1022.                                             {
  1023.                                                 OraTrace.Trace(16u, new string[]
  1024.                                                 {
  1025.                                                     string.Concat(new string[]
  1026.                                                     {
  1027.                                                         " (FO)    Failed over from ",
  1028.                                                         instanceName,
  1029.                                                         " to ",
  1030.                                                         pooledConCtx.opoConRefCtx.instanceName,
  1031.                                                         "\n"
  1032.                                                     })
  1033.                                                 });
  1034.                                                 connectionPool.m_conList.Remove(pooledConCtx);
  1035.                                                 if (OraTrace.m_TraceLevel != 0u)
  1036.                                                 {
  1037.                                                     OraTrace.Trace(16u, new string[]
  1038.                                                     {
  1039.                                                         string.Concat(new object[]
  1040.                                                         {
  1041.                                                             " (RegulateNumOfCons) Pool Id = ",
  1042.                                                             connectionPool.m_poolId,
  1043.                                                             " Removed(1) PooledConCtx= ",
  1044.                                                             pooledConCtx.GetHashCode(),
  1045.                                                             "\n"
  1046.                                                         })
  1047.                                                     });
  1048.                                                 }
  1049.                                                 flag = true;
  1050.                                                 connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[pooledConCtx.opoConRefCtx.instanceName];
  1051.                                                 if (connectionPool == null)
  1052.                                                 {
  1053.                                                     lock (this.m_cpCtx.htInstToCp.SyncRoot)
  1054.                                                     {
  1055.                                                         connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[pooledConCtx.opoConRefCtx.instanceName];
  1056.                                                         if (connectionPool == null)
  1057.                                                         {
  1058.                                                             OpoConCtx opoConCtx = new OpoConCtx();
  1059.                                                             opoConCtx.pooledConCtx = pooledConCtx;
  1060.                                                             opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
  1061.                                                             opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
  1062.                                                             opoConCtx.pOpoConValCtx = pooledConCtx.pOpoConValCtx;
  1063.                                                             opoConCtx.opoConRefCtx = pooledConCtx.opoConRefCtx;
  1064.                                                             connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
  1065.                                                             this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
  1066.                                                             if (OraTrace.m_TraceLevel != 0u)
  1067.                                                             {
  1068.                                                                 OraTrace.Trace(2u, new string[]
  1069.                                                                 {
  1070.                                                                     string.Concat(new object[]
  1071.                                                                     {
  1072.                                                                         " (POOL)  New CP created (CP id: ",
  1073.                                                                         connectionPool.GetHashCode(),
  1074.                                                                         "; CPCtx id: ",
  1075.                                                                         connectionPool.m_cpCtx.GetHashCode(),
  1076.                                                                         ") for: [Instance=",
  1077.                                                                         opoConCtx.opoConRefCtx.instanceName,
  1078.                                                                         "]\n"
  1079.                                                                     })
  1080.                                                                 });
  1081.                                                                 OraTrace.Trace(2u, new string[]
  1082.                                                                 {
  1083.                                                                     string.Concat(new object[]
  1084.                                                                     {
  1085.                                                                         " (POOL)  Num of Inst CPs in (CPCtx id: ",
  1086.                                                                         connectionPool.m_cpCtx.GetHashCode(),
  1087.                                                                         ") : ",
  1088.                                                                         connectionPool.m_cpCtx.htInstToCp.Count,
  1089.                                                                         "\n"
  1090.                                                                     })
  1091.                                                                 });
  1092.                                                             }
  1093.                                                         }
  1094.                                                     }
  1095.                                                 }
  1096.                                                 if (this.m_bSynchronizeStack)
  1097.                                                 {
  1098.                                                     lock (connectionPool.m_connections.SyncRoot)
  1099.                                                     {
  1100.                                                         connectionPool.m_connections.Push(pooledConCtx);
  1101.                                                         if (connectionPool.m_clonedCtx.gridCR == 1)
  1102.                                                         {
  1103.                                                             if (!connectionPool.m_conList.Contains(pooledConCtx))
  1104.                                                             {
  1105.                                                                 connectionPool.m_conList.Add(pooledConCtx);
  1106.                                                             }
  1107.                                                             if (OraTrace.m_TraceLevel != 0u)
  1108.                                                             {
  1109.                                                                 OraTrace.Trace(16u, new string[]
  1110.                                                                 {
  1111.                                                                     string.Concat(new object[]
  1112.                                                                     {
  1113.                                                                         " (RegulateNumOfCons) Pool Id = ",
  1114.                                                                         connectionPool.m_poolId,
  1115.                                                                         " Added(1) PooledConCtx= ",
  1116.                                                                         pooledConCtx.GetHashCode(),
  1117.                                                                         "\n"
  1118.                                                                     })
  1119.                                                                 });
  1120.                                                             }
  1121.                                                         }
  1122.                                                         goto IL_7D9;
  1123.                                                     }
  1124.                                                 }
  1125.                                                 connectionPool.m_connections.Push(pooledConCtx);
  1126.                                                 if (connectionPool.m_clonedCtx.gridCR == 1)
  1127.                                                 {
  1128.                                                     if (!connectionPool.m_conList.Contains(pooledConCtx))
  1129.                                                     {
  1130.                                                         connectionPool.m_conList.Add(pooledConCtx);
  1131.                                                     }
  1132.                                                     if (OraTrace.m_TraceLevel != 0u)
  1133.                                                     {
  1134.                                                         OraTrace.Trace(16u, new string[]
  1135.                                                         {
  1136.                                                             string.Concat(new object[]
  1137.                                                             {
  1138.                                                                 " (RegulateNumOfCons) Pool Id = ",
  1139.                                                                 connectionPool.m_poolId,
  1140.                                                                 " Added(2) PooledConCtx= ",
  1141.                                                                 pooledConCtx.GetHashCode(),
  1142.                                                                 "\n"
  1143.                                                             })
  1144.                                                         });
  1145.                                                     }
  1146.                                                 }
  1147.                                                 IL_7D9:
  1148.                                                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  1149.                                                 {
  1150.                                                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
  1151.                                                 }
  1152.                                                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  1153.                                                 {
  1154.                                                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
  1155.                                                 }
  1156.                                                 if (bGridRac && connectionPool.m_cpCtx != null)
  1157.                                                 {
  1158.                                                     Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
  1159.                                                 }
  1160.                                                 Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
  1161.                                                 connectionPool.ReleaseSemaphore();
  1162.                                                 Interlocked.Decrement(ref this.m_counter.total);
  1163.                                                 Interlocked.Increment(ref connectionPool.m_counter.total);
  1164.                                             }
  1165.                                             else
  1166.                                             {
  1167.                                                 num++;
  1168.                                                 this.UpdateTotalCount(-1, true);
  1169.                                             }
  1170.                                         }
  1171.                                         else
  1172.                                         {
  1173.                                             num++;
  1174.                                             this.UpdateTotalCount(-1, true);
  1175.                                         }
  1176.                                     }
  1177.                                     else
  1178.                                     {
  1179.                                         if (bGridRac && this.m_cpCtx != null && num5 == 0)
  1180.                                         {
  1181.                                             int num7 = 0;
  1182.                                             OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num7);
  1183.                                         }
  1184.                                         else
  1185.                                         {
  1186.                                             if (num6 == 0)
  1187.                                             {
  1188.                                                 int num8 = 0;
  1189.                                                 OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num8);
  1190.                                             }
  1191.                                         }
  1192.                                     }
  1193.                                 }
  1194.                                 catch (Exception ex)
  1195.                                 {
  1196.                                     if (OraTrace.m_TraceLevel != 0u)
  1197.                                     {
  1198.                                         OraTrace.TraceExceptionInfo(ex);
  1199.                                     }
  1200.                                 }
  1201.                                 if (pooledConCtx == null)
  1202.                                 {
  1203.                                     break;
  1204.                                 }
  1205.                                 if (!flag)
  1206.                                 {
  1207.                                     try
  1208.                                     {
  1209.                                         if (pooledConCtx.m_fetchArrayPooler != null)
  1210.                                         {
  1211.                                             pooledConCtx.m_fetchArrayPooler.Dispose();
  1212.                                             pooledConCtx.m_fetchArrayPooler = null;
  1213.                                         }
  1214.                                         if (!pooledConCtx.m_bOpsConCtxDisposed)
  1215.                                         {
  1216.                                             lock (pooledConCtx.m_syncObject)
  1217.                                             {
  1218.                                                 if (!pooledConCtx.m_bOpsConCtxDisposed)
  1219.                                                 {
  1220.                                                     if (this.m_clonedCtx.gridCR == 1)
  1221.                                                     {
  1222.                                                         this.m_conList.Remove(pooledConCtx);
  1223.                                                         if (OraTrace.m_TraceLevel != 0u)
  1224.                                                         {
  1225.                                                             OraTrace.Trace(16u, new string[]
  1226.                                                             {
  1227.                                                                 string.Concat(new object[]
  1228.                                                                 {
  1229.                                                                     " (RegulateNumOfCons) Pool Id = ",
  1230.                                                                     this.m_poolId,
  1231.                                                                     " Removed(2) PooledConCtx= ",
  1232.                                                                     pooledConCtx.GetHashCode(),
  1233.                                                                     "\n"
  1234.                                                                 })
  1235.                                                             });
  1236.                                                         }
  1237.                                                     }
  1238.                                                     OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  1239.                                                     pooledConCtx.m_bOpsConCtxDisposed = true;
  1240.                                                 }
  1241.                                             }
  1242.                                         }
  1243.                                     }
  1244.                                     catch (Exception ex2)
  1245.                                     {
  1246.                                         if (OraTrace.m_TraceLevel != 0u)
  1247.                                         {
  1248.                                             OraTrace.TraceExceptionInfo(ex2);
  1249.                                         }
  1250.                                     }
  1251.                                     finally
  1252.                                     {
  1253.                                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  1254.                                         {
  1255.                                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
  1256.                                         }
  1257.                                         pooledConCtx.opsConCtx = IntPtr.Zero;
  1258.                                         pooledConCtx.opsErrCtx = IntPtr.Zero;
  1259.                                         pooledConCtx.pOpoConValCtx = null;
  1260.                                         pooledConCtx.m_conPooler = null;
  1261.                                         pooledConCtx.m_udtDescPoolerByName = null;
  1262.                                         pooledConCtx.m_udtDescPoolerByTDO = null;
  1263.                                     }
  1264.                                 }
  1265.                             }
  1266.                         }
  1267.                     }
  1268.                 }
  1269.                 else
  1270.                 {
  1271.                     if (total == 0 && num2 == 0 && num3 == 0 && potentialTotal == 0 && flag2)
  1272.                     {
  1273.                         if (bGridRac)
  1274.                         {
  1275.                             lock (this.m_cpCtx.m_rlbCtx.htConToInst.SyncRoot)
  1276.                             {
  1277.                                 if (this.m_cpCtx.m_counter.total == 0 && this.m_cpCtx.totalAvaliableConnections == 0 && this.m_clonedCtx.origMinPoolSize == 0 && this.m_cpCtx.m_counter.potentialTotal == 0)
  1278.                                 {
  1279.                                     this.m_cpCtx.m_rlbCtx.htConToInst.Remove(this.m_clonedCtx.conString);
  1280.                                 }
  1281.                                 if (this.m_clonedCtx.metaPool == 1)
  1282.                                 {
  1283.                                     DeriveParamInfo.m_pooler.RemovePool(this.m_clonedCtx.conString);
  1284.                                 }
  1285.                                 this.m_cpCtx.m_timer.Dispose();
  1286.                                 goto IL_C7B;
  1287.                             }
  1288.                         }
  1289.                         lock (ConnectionDispenser.s_lockObj)
  1290.                         {
  1291.                             if (this.m_counter.total == 0 && this.m_connections.Count == 0 && this.m_clonedCtx.minPoolSize == 0 && this.m_counter.potentialTotal == 0)
  1292.                             {
  1293.                                 ConnectionPool connectionPool2 = (ConnectionPool)ConnectionDispenser.m_ConnectionPools[this.m_clonedCtx.conString];
  1294.                                 ConnectionDispenser.m_ConnectionPools.Remove(this.m_clonedCtx.conString);
  1295.                                 connectionPool2.Dispose();
  1296.                                 if (this.m_clonedCtx.metaPool == 1)
  1297.                                 {
  1298.                                     DeriveParamInfo.m_pooler.RemovePool(this.m_clonedCtx.conString);
  1299.                                 }
  1300.                                 this.m_timer.Dispose();
  1301.                             }
  1302.                             goto IL_C7B;
  1303.                         }
  1304.                     }
  1305.                     if (potentialTotal < num3)
  1306.                     {
  1307.                         int num9;
  1308.                         if (potentialTotal + this.m_clonedCtx.poolIncSize > this.m_clonedCtx.maxPoolSize)
  1309.                         {
  1310.                             num9 = this.m_clonedCtx.maxPoolSize - potentialTotal;
  1311.                         }
  1312.                         else
  1313.                         {
  1314.                             num9 = this.m_clonedCtx.poolIncSize;
  1315.                         }
  1316.                         if (num9 > 0)
  1317.                         {
  1318.                             ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), num9);
  1319.                             this.UpdatePotentialTotalCount(num9);
  1320.                         }
  1321.                     }
  1322.                 }
  1323.                 IL_C7B:;
  1324.             }
  1325.             catch
  1326.             {
  1327.             }
  1328.             finally
  1329.             {
  1330.                 if (this.m_cpCtx != null)
  1331.                 {
  1332.                     Monitor.Exit(this.m_cpCtx);
  1333.                 }
  1334.             }
  1335.             if (state == null)
  1336.             {
  1337.                 this.m_skipDecrement = false;
  1338.             }
  1339.             if (this.m_cpCtx != null)
  1340.             {
  1341.                 this.m_cpCtx.m_cpCtxSkipDecrement = false;
  1342.             }
  1343.             if ((bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0)
  1344.             {
  1345.                 if (!this.m_inactive)
  1346.                 {
  1347.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  1348.                     {
  1349.                         ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  1350.                     }
  1351.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  1352.                     {
  1353.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  1354.                     }
  1355.                     this.m_inactive = true;
  1356.                 }
  1357.             }
  1358.             else
  1359.             {
  1360.                 if (this.m_inactive)
  1361.                 {
  1362.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  1363.                     {
  1364.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  1365.                     }
  1366.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  1367.                     {
  1368.                         ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  1369.                     }
  1370.                     this.m_inactive = false;
  1371.                 }
  1372.             }
  1373.             return num;
  1374.         }
  1375.         public unsafe int CheckLifeTimeAndStatus(ref OpoConCtx opoConCtx, bool bDistTxnActive, ref bool bClosed, int bFromPool, bool bCheckLifetimeOnly, bool bFreeValCtxOnDispose)
  1376.         {
  1377.             int result = 0;
  1378.             bool bGridRac = opoConCtx.bGridRac;
  1379.             bool flag = false;
  1380.             OpoConValCtx* ptr = null;
  1381.             if ((!bGridRac || bFromPool != 1) && !bDistTxnActive)
  1382.             {
  1383.                 int total;
  1384.                 if (this.m_cpCtx != null)
  1385.                 {
  1386.                     total = this.m_cpCtx.m_counter.total;
  1387.                 }
  1388.                 else
  1389.                 {
  1390.                     total = this.m_counter.total;
  1391.                 }
  1392.                 bool flag2 = false;
  1393.                 try
  1394.                 {
  1395.                     Monitor.Enter(this, ref flag2);
  1396.                     if (this.m_rlbGravCounter > 0)
  1397.                     {
  1398.                         this.m_rlbGravCounter--;
  1399.                         flag = true;
  1400.                     }
  1401.                 }
  1402.                 finally
  1403.                 {
  1404.                     if (flag2)
  1405.                     {
  1406.                         Monitor.Exit(this);
  1407.                     }
  1408.                 }
  1409.                 if ((bFromPool != 0 || !(opoConCtx.lifeTime > TimeSpan.Zero) || total <= opoConCtx.minPoolSize || !(opoConCtx.lifeTime < DateTime.Now.Subtract(opoConCtx.creationTime))) && (!(this.m_clonedCtx.lifeTime == new TimeSpan(1L)) || !(this.m_clonedCtx.origLifeTime < DateTime.Now.Subtract(opoConCtx.creationTime))))
  1410.                 {
  1411.                     if (!flag)
  1412.                     {
  1413.                         goto IL_312;
  1414.                     }
  1415.                 }
  1416.                 try
  1417.                 {
  1418.                     if (opoConCtx.m_fetchArrayPooler != null)
  1419.                     {
  1420.                         opoConCtx.m_fetchArrayPooler.Dispose();
  1421.                         opoConCtx.m_fetchArrayPooler = null;
  1422.                     }
  1423.                     if (!opoConCtx.m_bOpsConCtxDisposed)
  1424.                     {
  1425.                         lock (opoConCtx.m_syncObject)
  1426.                         {
  1427.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  1428.                             {
  1429.                                 if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  1430.                                 {
  1431.                                     opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  1432.                                     if (OraTrace.m_TraceLevel != 0u)
  1433.                                     {
  1434.                                         OraTrace.Trace(16u, new string[]
  1435.                                         {
  1436.                                             string.Concat(new object[]
  1437.                                             {
  1438.                                                 " (CheckLifeTimeAndStatus) Pool Id = ",
  1439.                                                 opoConCtx.pool.m_poolId,
  1440.                                                 " Removed(1) PooledConCtx= ",
  1441.                                                 opoConCtx.pooledConCtx.GetHashCode(),
  1442.                                                 "\n"
  1443.                                             })
  1444.                                         });
  1445.                                     }
  1446.                                     opoConCtx.pooledConCtx.pOpoConValCtx = null;
  1447.                                 }
  1448.                                 if (bFreeValCtxOnDispose)
  1449.                                 {
  1450.                                     ptr = opoConCtx.pOpoConValCtx;
  1451.                                     opoConCtx.pOpoConValCtx = null;
  1452.                                 }
  1453.                                 OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
  1454.                                 opoConCtx.m_bOpsConCtxDisposed = true;
  1455.                                 if (opoConCtx.pooledConCtx != null)
  1456.                                 {
  1457.                                     opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  1458.                                 }
  1459.                             }
  1460.                         }
  1461.                     }
  1462.                 }
  1463.                 catch (Exception ex)
  1464.                 {
  1465.                     if (OraTrace.m_TraceLevel != 0u)
  1466.                     {
  1467.                         OraTrace.TraceExceptionInfo(ex);
  1468.                     }
  1469.                 }
  1470.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  1471.                 {
  1472.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  1473.                 }
  1474.                 opoConCtx.pooledConCtx = null;
  1475.                 opoConCtx.opsConCtx = IntPtr.Zero;
  1476.                 opoConCtx.opsErrCtx = IntPtr.Zero;
  1477.                 opoConCtx.m_conPooler = null;
  1478.                 opoConCtx.m_udtDescPoolerByName = null;
  1479.                 opoConCtx.m_udtDescPoolerByTDO = null;
  1480.                 opoConCtx.m_systemTransaction = null;
  1481.                 opoConCtx.m_txnType = TxnType.None;
  1482.                 this.UpdateTotalCount(-1, true);
  1483.                 bClosed = true;
  1484.                 if (flag)
  1485.                 {
  1486.                     this.UpdatePotentialTotalCount(1);
  1487.                     ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), 1);
  1488.                 }
  1489.                 return 0;
  1490.             }
  1491.             IL_312:
  1492.             if (bCheckLifetimeOnly)
  1493.             {
  1494.                 bClosed = false;
  1495.                 return 0;
  1496.             }
  1497.             try
  1498.             {
  1499.                 if (bFromPool == 0 && !bDistTxnActive && ((opoConCtx.opoConRefCtx.proxyUserId != null && opoConCtx.opoConRefCtx.proxyUserId.Length > 0) || opoConCtx.pOpoConValCtx->OSAuthent == 2))
  1500.                 {
  1501.                     OpsCon.CloseProxyAuthUserSession(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  1502.                 }
  1503.             }
  1504.             catch (Exception ex2)
  1505.             {
  1506.                 if (OraTrace.m_TraceLevel != 0u)
  1507.                 {
  1508.                     OraTrace.TraceExceptionInfo(ex2);
  1509.                 }
  1510.             }
  1511.             int num = 1;
  1512.             bool flag4 = false;
  1513.             try
  1514.             {
  1515.                 if (bFromPool == 0 || opoConCtx.validateCon == 1)
  1516.                 {
  1517.                     num = 0;
  1518.                     OpsCon.CheckConStatus(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opsErrCtx, bDistTxnActive ? 1 : 0, ref num, bFromPool, opoConCtx.validateCon);
  1519.                 }
  1520.             }
  1521.             catch (Exception ex3)
  1522.             {
  1523.                 flag4 = true;
  1524.                 if (OraTrace.m_TraceLevel != 0u)
  1525.                 {
  1526.                     OraTrace.TraceExceptionInfo(ex3);
  1527.                 }
  1528.             }
  1529.             if (num == 0)
  1530.             {
  1531.                 if (OraTrace.m_TraceLevel != 0u)
  1532.                 {
  1533.                     if (flag4)
  1534.                     {
  1535.                         OraTrace.Trace(1u, new string[]
  1536.                         {
  1537.                             " (VALID) Exception in OpsCon.CheckConStatus\n"
  1538.                         });
  1539.                     }
  1540.                     else
  1541.                     {
  1542.                         OraTrace.Trace(1u, new string[]
  1543.                         {
  1544.                             " (VALID) Dead connection\n"
  1545.                         });
  1546.                     }
  1547.                 }
  1548.                 try
  1549.                 {
  1550.                     if (opoConCtx.m_fetchArrayPooler != null)
  1551.                     {
  1552.                         opoConCtx.m_fetchArrayPooler.Dispose();
  1553.                         opoConCtx.m_fetchArrayPooler = null;
  1554.                     }
  1555.                     if (!opoConCtx.m_bOpsConCtxDisposed)
  1556.                     {
  1557.                         lock (opoConCtx.m_syncObject)
  1558.                         {
  1559.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  1560.                             {
  1561.                                 if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  1562.                                 {
  1563.                                     opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  1564.                                     if (OraTrace.m_TraceLevel != 0u)
  1565.                                     {
  1566.                                         OraTrace.Trace(16u, new string[]
  1567.                                         {
  1568.                                             string.Concat(new object[]
  1569.                                             {
  1570.                                                 " (CheckLifeTimeAndStatus) Pool Id = ",
  1571.                                                 opoConCtx.pool.m_poolId,
  1572.                                                 " Removed(2) PooledConCtx= ",
  1573.                                                 opoConCtx.pooledConCtx.GetHashCode(),
  1574.                                                 "\n"
  1575.                                             })
  1576.                                         });
  1577.                                     }
  1578.                                 }
  1579.                                 OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  1580.                                 if (bFromPool == 0 && bFreeValCtxOnDispose)
  1581.                                 {
  1582.                                     ptr = opoConCtx.pOpoConValCtx;
  1583.                                     opoConCtx.pOpoConValCtx = null;
  1584.                                 }
  1585.                                 OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
  1586.                                 opoConCtx.m_bOpsConCtxDisposed = true;
  1587.                                 if (opoConCtx.pooledConCtx != null)
  1588.                                 {
  1589.                                     opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  1590.                                 }
  1591.                             }
  1592.                         }
  1593.                     }
  1594.                 }
  1595.                 catch (Exception ex4)
  1596.                 {
  1597.                     if (OraTrace.m_TraceLevel != 0u)
  1598.                     {
  1599.                         OraTrace.TraceExceptionInfo(ex4);
  1600.                     }
  1601.                 }
  1602.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  1603.                 {
  1604.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  1605.                 }
  1606.                 opoConCtx.pooledConCtx = null;
  1607.                 opoConCtx.opsConCtx = IntPtr.Zero;
  1608.                 opoConCtx.opsErrCtx = IntPtr.Zero;
  1609.                 opoConCtx.m_conPooler = null;
  1610.                 opoConCtx.m_udtDescPoolerByName = null;
  1611.                 opoConCtx.m_udtDescPoolerByTDO = null;
  1612.                 opoConCtx.m_systemTransaction = null;
  1613.                 opoConCtx.m_txnType = TxnType.None;
  1614.                 this.UpdateTotalCount(-1, true);
  1615.                 bClosed = true;
  1616.             }
  1617.             else
  1618.             {
  1619.                 bClosed = false;
  1620.             }
  1621.             return result;
  1622.         }
  1623.         private unsafe void GetEnlistedConnection(ref PooledConCtx pooledConCtx, OpoConCtx opoConCtx)
  1624.         {
  1625.             try
  1626.             {
  1627.                 if (string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) && opoConCtx.pOpoConValCtx->OSAuthent != 2)
  1628.                 {
  1629.                     pooledConCtx = (PooledConCtx)this.m_oraResPool.GetResource(opoConCtx.m_systemTransaction.TransactionInformation.LocalIdentifier);
  1630.                 }
  1631.                 else
  1632.                 {
  1633.                     string userID = opoConCtx.opoConRefCtx.userID;
  1634.                     string password = opoConCtx.opoConRefCtx.password;
  1635.                     pooledConCtx = opoConCtx.pool.m_oraResPool.GetResourceMatchingEndUser(Transaction.Current.TransactionInformation.LocalIdentifier, userID, password);
  1636.                 }
  1637.                 if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  1638.                 {
  1639.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  1640.                 }
  1641.             }
  1642.             catch
  1643.             {
  1644.             }
  1645.         }
  1646.         private void GetRegularConnection(ref PooledConCtx pooledConCtx)
  1647.         {
  1648.             try
  1649.             {
  1650.                 if (this.m_bSynchronizeStack)
  1651.                 {
  1652.                     lock (this.m_connections.SyncRoot)
  1653.                     {
  1654.                         pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  1655.                         goto IL_4E;
  1656.                     }
  1657.                 }
  1658.                 pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  1659.                 IL_4E:
  1660.                 if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  1661.                 {
  1662.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
  1663.                 }
  1664.             }
  1665.             catch
  1666.             {
  1667.             }
  1668.         }
  1669.         public unsafe int CopyPooledToCon(ref OpoConCtx opoConCtx, ref PooledConCtx pooledConCtx, bool bOpenEndUserSession)
  1670.         {
  1671.             int num = 0;
  1672.             int num2 = 0;
  1673.             int sessionBegin = 1;
  1674.             opoConCtx.pooledConCtx = pooledConCtx;
  1675.             if (opoConCtx.opsConCtx != IntPtr.Zero && opoConCtx.opsErrCtx != IntPtr.Zero)
  1676.             {
  1677.                 OpoConValCtx* ptr = null;
  1678.                 try
  1679.                 {
  1680.                     if (opoConCtx.m_fetchArrayPooler != null)
  1681.                     {
  1682.                         opoConCtx.m_fetchArrayPooler.Dispose();
  1683.                         opoConCtx.m_fetchArrayPooler = null;
  1684.                     }
  1685.                     if (!opoConCtx.m_bOpsConCtxDisposed)
  1686.                     {
  1687.                         lock (opoConCtx.m_syncObject)
  1688.                         {
  1689.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  1690.                             {
  1691.                                 if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  1692.                                 {
  1693.                                     opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  1694.                                     if (OraTrace.m_TraceLevel != 0u)
  1695.                                     {
  1696.                                         OraTrace.Trace(16u, new string[]
  1697.                                         {
  1698.                                             string.Concat(new object[]
  1699.                                             {
  1700.                                                 " (CopyPooledToCon) Pool Id = ",
  1701.                                                 opoConCtx.pool.m_poolId,
  1702.                                                 " Removed PooledConCtx= ",
  1703.                                                 opoConCtx.pooledConCtx.GetHashCode(),
  1704.                                                 "\n"
  1705.                                             })
  1706.                                         });
  1707.                                     }
  1708.                                 }
  1709.                                 OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
  1710.                                 opoConCtx.m_bOpsConCtxDisposed = true;
  1711.                                 if (opoConCtx.pooledConCtx != null)
  1712.                                 {
  1713.                                     opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  1714.                                 }
  1715.                             }
  1716.                         }
  1717.                     }
  1718.                 }
  1719.                 catch (Exception ex)
  1720.                 {
  1721.                     if (OraTrace.m_TraceLevel != 0u)
  1722.                     {
  1723.                         OraTrace.TraceExceptionInfo(ex);
  1724.                     }
  1725.                 }
  1726.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  1727.                 {
  1728.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  1729.                 }
  1730.             }
  1731.             opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
  1732.             opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
  1733.             opoConCtx.creationTime = pooledConCtx.creationTime;
  1734.             opoConCtx.m_syncObject = pooledConCtx.m_syncObject;
  1735.             num = ConnectionDispenser.CopyPooledConCtx(ref opoConCtx.pOpoConValCtx, pooledConCtx.pOpoConValCtx);
  1736.             try
  1737.             {
  1738.                 if (num == 0 && bOpenEndUserSession && opoConCtx.pOpoConValCtx->SessionBegin == 1)
  1739.                 {
  1740.                     if (opoConCtx.opoConRefCtx.proxyUserId == null || opoConCtx.opoConRefCtx.proxyUserId.Length <= 0)
  1741.                     {
  1742.                         if (opoConCtx.pOpoConValCtx->OSAuthent != 2)
  1743.                         {
  1744.                             goto IL_28F;
  1745.                         }
  1746.                     }
  1747.                     try
  1748.                     {
  1749.                         num2 = OpsCon.OpenProxyAuthUserSession(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  1750.                     }
  1751.                     catch (Exception ex2)
  1752.                     {
  1753.                         if (OraTrace.m_TraceLevel != 0u)
  1754.                         {
  1755.                             OraTrace.TraceExceptionInfo(ex2);
  1756.                         }
  1757.                         num = ErrRes.INT_ERR;
  1758.                         opoConCtx.exceptMsg = ex2.ToString();
  1759.                     }
  1760.                 }
  1761.                 IL_28F:;
  1762.             }
  1763.             finally
  1764.             {
  1765.                 if (num2 != 0)
  1766.                 {
  1767.                     sessionBegin = opoConCtx.pOpoConValCtx->SessionBegin;
  1768.                     opoConCtx.pOpoConValCtx->SessionBegin = 1;
  1769.                     num = num2;
  1770.                 }
  1771.                 if (num != 0)
  1772.                 {
  1773.                     if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.m_systemTransaction != null)
  1774.                     {
  1775.                         this.PushToResourcePool(opoConCtx, pooledConCtx);
  1776.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  1777.                         {
  1778.                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  1779.                         }
  1780.                     }
  1781.                     else
  1782.                     {
  1783.                         if (this.m_bSynchronizeStack)
  1784.                         {
  1785.                             lock (this.m_connections)
  1786.                             {
  1787.                                 this.PutConnection(ref opoConCtx, false, true, true, 0, false, true);
  1788.                                 goto IL_342;
  1789.                             }
  1790.                         }
  1791.                         this.PutConnection(ref opoConCtx, false, true, true, 0, false, true);
  1792.                     }
  1793.                     IL_342:
  1794.                     opoConCtx.pooledConCtx = null;
  1795.                     opoConCtx.opsConCtx = IntPtr.Zero;
  1796.                     opoConCtx.opsErrCtx = IntPtr.Zero;
  1797.                     opoConCtx.m_conPooler = null;
  1798.                     opoConCtx.m_udtDescPoolerByName = null;
  1799.                     opoConCtx.m_udtDescPoolerByTDO = null;
  1800.                 }
  1801.             }
  1802.             opoConCtx.opoConRefCtx.serverVersion = pooledConCtx.opoConRefCtx.serverVersion;
  1803.             opoConCtx.opoConRefCtx.dataSource = pooledConCtx.opoConRefCtx.dataSource;
  1804.             opoConCtx.opoConRefCtx.dbName = pooledConCtx.opoConRefCtx.dbName;
  1805.             opoConCtx.opoConRefCtx.hostName = pooledConCtx.opoConRefCtx.hostName;
  1806.             opoConCtx.opoConRefCtx.serviceName = pooledConCtx.opoConRefCtx.serviceName;
  1807.             opoConCtx.opoConRefCtx.instanceName = pooledConCtx.opoConRefCtx.instanceName;
  1808.             opoConCtx.opoConRefCtx.dbDomainName = pooledConCtx.opoConRefCtx.dbDomainName;
  1809.             opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg = pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
  1810.             opoConCtx.m_conPooler = pooledConCtx.m_conPooler;
  1811.             opoConCtx.m_udtDescPoolerByName = pooledConCtx.m_udtDescPoolerByName;
  1812.             opoConCtx.m_udtDescPoolerByTDO = pooledConCtx.m_udtDescPoolerByTDO;
  1813.             opoConCtx.m_txnid = pooledConCtx.m_txnid;
  1814.             opoConCtx.m_promotableTxnManager = pooledConCtx.m_promotableTxnManager;
  1815.             opoConCtx.m_fetchArrayPooler = pooledConCtx.m_fetchArrayPooler;
  1816.             opoConCtx.m_statementData = pooledConCtx.m_statementData;
  1817.             opoConCtx.m_totalDataAvailable = pooledConCtx.m_totalDataAvailable;
  1818.             if (num2 != 0)
  1819.             {
  1820.                 opoConCtx.pOpoConValCtx->SessionBegin = sessionBegin;
  1821.             }
  1822.             return num;
  1823.         }
  1824.         private void CreateMoreConnections()
  1825.         {
  1826.             int potentialTotal;
  1827.             if (this.m_cpCtx != null)
  1828.             {
  1829.                 potentialTotal = this.m_cpCtx.m_counter.potentialTotal;
  1830.             }
  1831.             else
  1832.             {
  1833.                 potentialTotal = this.m_counter.potentialTotal;
  1834.             }
  1835.             int num;
  1836.             if (potentialTotal + this.m_clonedCtx.poolIncSize > this.m_clonedCtx.maxPoolSize)
  1837.             {
  1838.                 num = this.m_clonedCtx.maxPoolSize - potentialTotal;
  1839.             }
  1840.             else
  1841.             {
  1842.                 num = this.m_clonedCtx.poolIncSize;
  1843.             }
  1844.             if (num > 0)
  1845.             {
  1846.                 ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), num);
  1847.                 this.UpdatePotentialTotalCount(num);
  1848.             }
  1849.         }
  1850.         private int WaitForRegularConnection(ref OpoConCtx opoConCtx, ref PooledConCtx pooledConCtx)
  1851.         {
  1852.             int num = 0;
  1853.             int num2 = 0;
  1854.             this.UpdateThreadWaitCount(1);
  1855.             double num3;
  1856.             if (this.m_bGridRac)
  1857.             {
  1858.                 num3 = 0.0;
  1859.             }
  1860.             else
  1861.             {
  1862.                 num3 = opoConCtx.timeOut.TotalSeconds;
  1863.             }
  1864.             try
  1865.             {
  1866.                 num = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, (int)num3 * 1000);
  1867.             }
  1868.             catch (Exception ex)
  1869.             {
  1870.                 if (OraTrace.m_TraceLevel != 0u)
  1871.                 {
  1872.                     OraTrace.TraceExceptionInfo(ex);
  1873.                 }
  1874.                 num = ErrRes.INT_ERR;
  1875.                 opoConCtx.exceptMsg = ex.ToString();
  1876.             }
  1877.             finally
  1878.             {
  1879.                 this.UpdateThreadWaitCount(-1);
  1880.             }
  1881.             if (num == ErrRes.INT_ERR)
  1882.             {
  1883.                 return num;
  1884.             }
  1885.             int num4 = num;
  1886.             if (num4 != 0)
  1887.             {
  1888.                 if (num4 == 128 || num4 == 258)
  1889.                 {
  1890.                     if (this.m_bGridRac)
  1891.                     {
  1892.                         Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
  1893.                     }
  1894.                     else
  1895.                     {
  1896.                         Interlocked.Increment(ref this.m_counter.totalAvailable);
  1897.                     }
  1898.                     if (!(this.m_bGridRac ? (this.m_cpCtx.m_counter.total >= this.m_cpCtx.m_maxPoolSize) : (this.m_counter.total >= this.m_clonedCtx.maxPoolSize)))
  1899.                     {
  1900.                         return ErrRes.CON_TIMEOUT_EXCEEDED;
  1901.                     }
  1902.                     return ErrRes.CON_POOLED_TIMEOUT_EXCEEDED;
  1903.                 }
  1904.             }
  1905.             else
  1906.             {
  1907.                 this.GetRegularConnection(ref pooledConCtx);
  1908.                 if (pooledConCtx == null)
  1909.                 {
  1910.                     num = ((this.m_bGridRac ? (this.m_cpCtx.m_counter.total >= this.m_cpCtx.m_maxPoolSize) : (this.m_counter.total >= this.m_clonedCtx.maxPoolSize)) ? ErrRes.CON_POOLED_TIMEOUT_EXCEEDED : ErrRes.CON_TIMEOUT_EXCEEDED);
  1911.                     if (this.m_bGridRac)
  1912.                     {
  1913.                         Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
  1914.                     }
  1915.                     else
  1916.                     {
  1917.                         Interlocked.Increment(ref this.m_counter.totalAvailable);
  1918.                     }
  1919.                     try
  1920.                     {
  1921.                         OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num2);
  1922.                     }
  1923.                     catch (Exception ex2)
  1924.                     {
  1925.                         if (OraTrace.m_TraceLevel != 0u)
  1926.                         {
  1927.                             OraTrace.TraceExceptionInfo(ex2);
  1928.                         }
  1929.                     }
  1930.                     return num;
  1931.                 }
  1932.             }
  1933.             return 0;
  1934.         }
  1935.         public unsafe int GetConnection(OpoConCtx opoConCtx)
  1936.         {
  1937.             int num = 0;
  1938.             PooledConCtx pooledConCtx = null;
  1939.             bool flag = false;
  1940.             bool flag2 = false;
  1941.             bool flag3 = false;
  1942.             DateTime now = DateTime.Now;
  1943.             try
  1944.             {
  1945.                 if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.m_systemTransaction != null)
  1946.                 {
  1947.                     flag2 = true;
  1948.                 }
  1949.                 while (true)
  1950.                 {
  1951.                     flag = false;
  1952.                     pooledConCtx = null;
  1953.                     int inMtsTxn = 0;
  1954.                     if (flag2)
  1955.                     {
  1956.                         this.GetEnlistedConnection(ref pooledConCtx, opoConCtx);
  1957.                         if (pooledConCtx != null)
  1958.                         {
  1959.                             inMtsTxn = 1;
  1960.                             flag3 = true;
  1961.                             if (opoConCtx.bGridRac && this.m_cpCtx != null)
  1962.                             {
  1963.                                 Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
  1964.                                 Interlocked.Increment(ref this.m_counter.totalAvailable);
  1965.                                 int num2 = 0;
  1966.                                 OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num2);
  1967.                             }
  1968.                         }
  1969.                     }
  1970.                     if (pooledConCtx == null)
  1971.                     {
  1972.                         num = this.WaitForRegularConnection(ref opoConCtx, ref pooledConCtx);
  1973.                         if (num != 0)
  1974.                         {
  1975.                             break;
  1976.                         }
  1977.                     }
  1978.                     if (pooledConCtx != null)
  1979.                     {
  1980.                         num = this.CopyPooledToCon(ref opoConCtx, ref pooledConCtx, !flag3);
  1981.                         if (num != 0)
  1982.                         {
  1983.                             goto Block_17;
  1984.                         }
  1985.                     }
  1986.                     if (opoConCtx.pOpoConValCtx->SessionBegin == 1 && opoConCtx.validateCon == 1)
  1987.                     {
  1988.                         this.CheckLifeTimeAndStatus(ref opoConCtx, flag3, ref flag, 1, false, false);
  1989.                     }
  1990.                     if (!flag)
  1991.                     {
  1992.                         goto Block_20;
  1993.                     }
  1994.                     if (DateTime.Now - now >= opoConCtx.timeOut)
  1995.                     {
  1996.                         goto Block_24;
  1997.                     }
  1998.                 }
  1999.                 if (opoConCtx.bGridRac && this.m_cpCtx != null)
  2000.                 {
  2001.                     int num3 = 0;
  2002.                     OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num3);
  2003.                 }
  2004.                 int result = num;
  2005.                 return result;
  2006.                 Block_17:
  2007.                 result = num;
  2008.                 return result;
  2009.                 Block_20:
  2010.                 bool flag4 = true;
  2011.                 if (!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2)
  2012.                 {
  2013.                     flag4 = false;
  2014.                 }
  2015.                 if (flag2 && flag4)
  2016.                 {
  2017.                     int inMtsTxn;
  2018.                     opoConCtx.pOpoConValCtx->InMtsTxn = inMtsTxn;
  2019.                 }
  2020.                 if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.pOpoConValCtx->InMtsTxn == 0 && opoConCtx.pOpoConValCtx->SessionBegin == 1)
  2021.                 {
  2022.                     if (opoConCtx.opoConRefCtx.proxyUserId != null)
  2023.                     {
  2024.                         if (opoConCtx.opoConRefCtx.proxyUserId.Length != 0)
  2025.                         {
  2026.                             goto IL_275;
  2027.                         }
  2028.                     }
  2029.                     try
  2030.                     {
  2031.                         num = OpsCon.Enlist(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2032.                     }
  2033.                     catch (Exception ex)
  2034.                     {
  2035.                         if (OraTrace.m_TraceLevel != 0u)
  2036.                         {
  2037.                             OraTrace.TraceExceptionInfo(ex);
  2038.                         }
  2039.                         num = ErrRes.INT_ERR;
  2040.                         opoConCtx.exceptMsg = ex.ToString();
  2041.                     }
  2042.                     finally
  2043.                     {
  2044.                         if (num != 0)
  2045.                         {
  2046.                             opoConCtx.pOpoConValCtx->InMtsTxn = 0;
  2047.                             if (this.m_bSynchronizeStack)
  2048.                             {
  2049.                                 lock (this.m_connections)
  2050.                                 {
  2051.                                     this.PutConnection(ref opoConCtx, false, true, true, 0, false, false);
  2052.                                     goto IL_26C;
  2053.                                 }
  2054.                             }
  2055.                             this.PutConnection(ref opoConCtx, false, true, true, 0, false, false);
  2056.                         }
  2057.                         IL_26C:;
  2058.                     }
  2059.                     if (num != 0)
  2060.                     {
  2061.                         result = num;
  2062.                         return result;
  2063.                     }
  2064.                 }
  2065.                 IL_275:
  2066.                 goto IL_28E;
  2067.                 Block_24:
  2068.                 result = ErrRes.CON_TIMEOUT_EXCEEDED;
  2069.                 return result;
  2070.             }
  2071.             catch (Exception ex2)
  2072.             {
  2073.                 num = ErrRes.INT_ERR;
  2074.                 opoConCtx.exceptMsg = ex2.ToString();
  2075.             }
  2076.             IL_28E:
  2077.             if (this.m_inactive)
  2078.             {
  2079.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  2080.                 {
  2081.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, opoConCtx);
  2082.                 }
  2083.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  2084.                 {
  2085.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, opoConCtx);
  2086.                 }
  2087.                 this.m_inactive = false;
  2088.             }
  2089.             return num;
  2090.         }
  2091.         public int ReleaseSemaphore()
  2092.         {
  2093.             int num = 0;
  2094.             int num2 = 0;
  2095.             try
  2096.             {
  2097.                 OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num);
  2098.                 if (this.m_cpCtx != null)
  2099.                 {
  2100.                     OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num2);
  2101.                 }
  2102.             }
  2103.             catch (Exception ex)
  2104.             {
  2105.                 if (OraTrace.m_TraceLevel != 0u)
  2106.                 {
  2107.                     OraTrace.TraceExceptionInfo(ex);
  2108.                 }
  2109.             }
  2110.             return 0;
  2111.         }
  2112.         public unsafe int PutConnection(ref OpoConCtx opoConCtx, bool bDoNotAllocValCtx, bool bCheckStatus, bool bCheckLifeTime, int bDistTxnActive, bool isPopulatePool, bool bFreeValCtxOnDispose)
  2113.         {
  2114.             bool flag = false;
  2115.             int num = 0;
  2116.             bool flag2 = false;
  2117.             ConnectionPool connectionPool = this;
  2118.             if (opoConCtx.pOpoConValCtx->StmtCacheSize > 0 && opoConCtx.pOpoConValCtx->StmtCachePurge == 1)
  2119.             {
  2120.                 try
  2121.                 {
  2122.                     num = OpsCon.PurgeStatementCache(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx);
  2123.                 }
  2124.                 catch (Exception ex)
  2125.                 {
  2126.                     if (OraTrace.m_TraceLevel != 0u)
  2127.                     {
  2128.                         OraTrace.TraceExceptionInfo(ex);
  2129.                     }
  2130.                 }
  2131.             }
  2132.             if ((opoConCtx.pOpoConValCtx->InMtsTxn == 1 && opoConCtx.m_systemTransaction != null) || opoConCtx.m_promotableTxnManager != null)
  2133.             {
  2134.                 if (bCheckStatus)
  2135.                 {
  2136.                     this.CheckLifeTimeAndStatus(ref opoConCtx, true, ref flag, 0, false, bFreeValCtxOnDispose);
  2137.                     if (flag)
  2138.                     {
  2139.                         if (opoConCtx.m_promotableTxnManager != null)
  2140.                         {
  2141.                             opoConCtx.m_promotableTxnManager.m_bConnectionClosed = true;
  2142.                         }
  2143.                         return -1;
  2144.                     }
  2145.                 }
  2146.                 if (opoConCtx.pooledConCtx != null)
  2147.                 {
  2148.                     opoConCtx.pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
  2149.                     opoConCtx.pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
  2150.                     opoConCtx.pooledConCtx.m_statementData = opoConCtx.m_statementData;
  2151.                     opoConCtx.pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
  2152.                     opoConCtx.pooledConCtx.m_txnid = opoConCtx.m_txnid;
  2153.                     opoConCtx.pooledConCtx.pOpoConValCtx->InMtsTxn = (*opoConCtx.pOpoConValCtx).InMtsTxn;
  2154.                     opoConCtx.pooledConCtx.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
  2155.                     if ((!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2) && (opoConCtx.pooledConCtx.m_encryptedPassword == null || opoConCtx.pooledConCtx.m_encryptedPassword.Password != opoConCtx.opoConRefCtx.password))
  2156.                     {
  2157.                         opoConCtx.pooledConCtx.m_encryptedPassword = new EncryptedPassword(opoConCtx.opoConRefCtx.password);
  2158.                     }
  2159.                     this.PushToResourcePool(opoConCtx, opoConCtx.pooledConCtx);
  2160.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  2161.                     {
  2162.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  2163.                     }
  2164.                     opoConCtx.pooledConCtx = null;
  2165.                     opoConCtx.opsConCtx = IntPtr.Zero;
  2166.                     opoConCtx.opsErrCtx = IntPtr.Zero;
  2167.                     opoConCtx.m_conPooler = null;
  2168.                     opoConCtx.m_udtDescPoolerByName = null;
  2169.                     opoConCtx.m_udtDescPoolerByTDO = null;
  2170.                 }
  2171.                 else
  2172.                 {
  2173.                     PooledConCtx pooledConCtx = new PooledConCtx();
  2174.                     pooledConCtx.opsConCtx = opoConCtx.opsConCtx;
  2175.                     pooledConCtx.opsErrCtx = opoConCtx.opsErrCtx;
  2176.                     pooledConCtx.conString = opoConCtx.conString;
  2177.                     pooledConCtx.creationTime = opoConCtx.creationTime;
  2178.                     pooledConCtx.m_poolName = opoConCtx.poolName;
  2179.                     pooledConCtx.m_syncObject = opoConCtx.m_syncObject;
  2180.                     if (bDoNotAllocValCtx)
  2181.                     {
  2182.                         pooledConCtx.pOpoConValCtx = opoConCtx.pOpoConValCtx;
  2183.                         opoConCtx.pOpoConValCtx = null;
  2184.                     }
  2185.                     else
  2186.                     {
  2187.                         num = ConnectionDispenser.CopyPooledConCtx(ref pooledConCtx.pOpoConValCtx, opoConCtx.pOpoConValCtx);
  2188.                         if (num != 0)
  2189.                         {
  2190.                             try
  2191.                             {
  2192.                                 if (opoConCtx.m_fetchArrayPooler != null)
  2193.                                 {
  2194.                                     opoConCtx.m_fetchArrayPooler.Dispose();
  2195.                                     opoConCtx.m_fetchArrayPooler = null;
  2196.                                 }
  2197.                                 if (!opoConCtx.m_bOpsConCtxDisposed)
  2198.                                 {
  2199.                                     lock (opoConCtx.m_syncObject)
  2200.                                     {
  2201.                                         if (!opoConCtx.m_bOpsConCtxDisposed)
  2202.                                         {
  2203.                                             if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2204.                                             {
  2205.                                                 opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2206.                                                 if (OraTrace.m_TraceLevel != 0u)
  2207.                                                 {
  2208.                                                     OraTrace.Trace(16u, new string[]
  2209.                                                     {
  2210.                                                         string.Concat(new object[]
  2211.                                                         {
  2212.                                                             " (PutConnection) Pool Id = ",
  2213.                                                             opoConCtx.pool.m_poolId,
  2214.                                                             " Removed(0) PooledConCtx= ",
  2215.                                                             opoConCtx.pooledConCtx.GetHashCode(),
  2216.                                                             "\n"
  2217.                                                         })
  2218.                                                     });
  2219.                                                 }
  2220.                                                 opoConCtx.pooledConCtx.pOpoConValCtx = null;
  2221.                                             }
  2222.                                             OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2223.                                             opoConCtx.m_bOpsConCtxDisposed = true;
  2224.                                             if (opoConCtx.pooledConCtx != null)
  2225.                                             {
  2226.                                                 opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2227.                                             }
  2228.                                         }
  2229.                                     }
  2230.                                 }
  2231.                             }
  2232.                             catch (Exception ex2)
  2233.                             {
  2234.                                 if (OraTrace.m_TraceLevel != 0u)
  2235.                                 {
  2236.                                     OraTrace.TraceExceptionInfo(ex2);
  2237.                                 }
  2238.                             }
  2239.                             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  2240.                             {
  2241.                                 ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  2242.                             }
  2243.                             opoConCtx.pooledConCtx = null;
  2244.                             opoConCtx.opsConCtx = IntPtr.Zero;
  2245.                             opoConCtx.opsErrCtx = IntPtr.Zero;
  2246.                             opoConCtx.m_conPooler = null;
  2247.                             opoConCtx.m_udtDescPoolerByName = null;
  2248.                             opoConCtx.m_udtDescPoolerByTDO = null;
  2249.                             opoConCtx.m_systemTransaction = null;
  2250.                             opoConCtx.m_txnType = TxnType.None;
  2251.                             opoConCtx.m_promotableTxnManager = null;
  2252.                             this.UpdateTotalCount(-1, true);
  2253.                             return -1;
  2254.                         }
  2255.                     }
  2256.                     pooledConCtx.opoConRefCtx = new OpoConRefCtx();
  2257.                     pooledConCtx.opoConRefCtx.serverVersion = opoConCtx.opoConRefCtx.serverVersion;
  2258.                     pooledConCtx.opoConRefCtx.dataSource = opoConCtx.opoConRefCtx.dataSource;
  2259.                     pooledConCtx.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
  2260.                     pooledConCtx.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
  2261.                     pooledConCtx.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
  2262.                     pooledConCtx.opoConRefCtx.instanceName = opoConCtx.opoConRefCtx.instanceName;
  2263.                     pooledConCtx.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
  2264.                     pooledConCtx.opoConRefCtx.proxyUserId = opoConCtx.opoConRefCtx.proxyUserId;
  2265.                     pooledConCtx.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
  2266.                     pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg = opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
  2267.                     pooledConCtx.m_conPooler = opoConCtx.m_conPooler;
  2268.                     pooledConCtx.m_udtDescPoolerByName = opoConCtx.m_udtDescPoolerByName;
  2269.                     pooledConCtx.m_udtDescPoolerByTDO = opoConCtx.m_udtDescPoolerByTDO;
  2270.                     pooledConCtx.m_txnid = opoConCtx.m_txnid;
  2271.                     pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
  2272.                     pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
  2273.                     pooledConCtx.m_statementData = opoConCtx.m_statementData;
  2274.                     pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
  2275.                     if (!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2)
  2276.                     {
  2277.                         pooledConCtx.m_encryptedPassword = new EncryptedPassword(opoConCtx.opoConRefCtx.password);
  2278.                     }
  2279.                     this.PushToResourcePool(opoConCtx, pooledConCtx);
  2280.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  2281.                     {
  2282.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  2283.                     }
  2284.                     opoConCtx.pooledConCtx = null;
  2285.                     opoConCtx.opsConCtx = IntPtr.Zero;
  2286.                     opoConCtx.opsErrCtx = IntPtr.Zero;
  2287.                     opoConCtx.m_conPooler = null;
  2288.                     opoConCtx.m_udtDescPoolerByName = null;
  2289.                     opoConCtx.m_udtDescPoolerByTDO = null;
  2290.                 }
  2291.                 opoConCtx.pOpoConValCtx->InMtsTxn = 0;
  2292.                 return num;
  2293.             }
  2294.             if (opoConCtx.pOpoConValCtx->InMtsTxn == 1 && opoConCtx.m_systemTransaction == null)
  2295.             {
  2296.                 opoConCtx.opoConRefCtx.pITransaction = null;
  2297.                 try
  2298.                 {
  2299.                     num = OpsCon.Enlist(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2300.                 }
  2301.                 catch (Exception ex3)
  2302.                 {
  2303.                     if (OraTrace.m_TraceLevel != 0u)
  2304.                     {
  2305.                         OraTrace.TraceExceptionInfo(ex3);
  2306.                     }
  2307.                     num = ErrRes.INT_ERR;
  2308.                 }
  2309.                 finally
  2310.                 {
  2311.                     opoConCtx.pOpoConValCtx->InMtsTxn = 0;
  2312.                     if (num != 0)
  2313.                     {
  2314.                         try
  2315.                         {
  2316.                             if (opoConCtx.m_fetchArrayPooler != null)
  2317.                             {
  2318.                                 opoConCtx.m_fetchArrayPooler.Dispose();
  2319.                                 opoConCtx.m_fetchArrayPooler = null;
  2320.                             }
  2321.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  2322.                             {
  2323.                                 lock (opoConCtx.m_syncObject)
  2324.                                 {
  2325.                                     if (!opoConCtx.m_bOpsConCtxDisposed)
  2326.                                     {
  2327.                                         if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2328.                                         {
  2329.                                             opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2330.                                             if (OraTrace.m_TraceLevel != 0u)
  2331.                                             {
  2332.                                                 OraTrace.Trace(16u, new string[]
  2333.                                                 {
  2334.                                                     string.Concat(new object[]
  2335.                                                     {
  2336.                                                         " (PutConnection) Pool Id = ",
  2337.                                                         opoConCtx.pool.m_poolId,
  2338.                                                         " Removed(1) PooledConCtx= ",
  2339.                                                         opoConCtx.pooledConCtx.GetHashCode(),
  2340.                                                         "\n"
  2341.                                                     })
  2342.                                                 });
  2343.                                             }
  2344.                                             opoConCtx.pooledConCtx.pOpoConValCtx = null;
  2345.                                         }
  2346.                                         OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2347.                                         opoConCtx.m_bOpsConCtxDisposed = true;
  2348.                                         if (opoConCtx.pooledConCtx != null)
  2349.                                         {
  2350.                                             opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2351.                                         }
  2352.                                     }
  2353.                                 }
  2354.                             }
  2355.                         }
  2356.                         catch (Exception ex4)
  2357.                         {
  2358.                             if (OraTrace.m_TraceLevel != 0u)
  2359.                             {
  2360.                                 OraTrace.TraceExceptionInfo(ex4);
  2361.                             }
  2362.                         }
  2363.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  2364.                         {
  2365.                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  2366.                         }
  2367.                         opoConCtx.pooledConCtx = null;
  2368.                         opoConCtx.opsConCtx = IntPtr.Zero;
  2369.                         opoConCtx.opsErrCtx = IntPtr.Zero;
  2370.                         opoConCtx.m_conPooler = null;
  2371.                         opoConCtx.m_udtDescPoolerByName = null;
  2372.                         opoConCtx.m_udtDescPoolerByTDO = null;
  2373.                         opoConCtx.m_systemTransaction = null;
  2374.                         opoConCtx.m_txnType = TxnType.None;
  2375.                         this.UpdateTotalCount(-1, true);
  2376.                     }
  2377.                 }
  2378.                 if (num != 0)
  2379.                 {
  2380.                     return -1;
  2381.                 }
  2382.             }
  2383.             if (bCheckStatus || bCheckLifeTime)
  2384.             {
  2385.                 bool bCheckLifetimeOnly = bCheckLifeTime && !bCheckStatus;
  2386.                 this.CheckLifeTimeAndStatus(ref opoConCtx, false, ref flag, 0, bCheckLifetimeOnly, bFreeValCtxOnDispose);
  2387.                 if (flag)
  2388.                 {
  2389.                     return -1;
  2390.                 }
  2391.             }
  2392.             if (this.m_bClearPoolInProgress && opoConCtx.creationTime < this.m_clearRequestTimeStamp)
  2393.             {
  2394.                 try
  2395.                 {
  2396.                     if (opoConCtx.m_fetchArrayPooler != null)
  2397.                     {
  2398.                         opoConCtx.m_fetchArrayPooler.Dispose();
  2399.                         opoConCtx.m_fetchArrayPooler = null;
  2400.                     }
  2401.                     if (!opoConCtx.m_bOpsConCtxDisposed)
  2402.                     {
  2403.                         lock (opoConCtx.m_syncObject)
  2404.                         {
  2405.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  2406.                             {
  2407.                                 if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2408.                                 {
  2409.                                     opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2410.                                     if (OraTrace.m_TraceLevel != 0u)
  2411.                                     {
  2412.                                         OraTrace.Trace(16u, new string[]
  2413.                                         {
  2414.                                             string.Concat(new object[]
  2415.                                             {
  2416.                                                 " (PutConnection) Pool Id = ",
  2417.                                                 opoConCtx.pool.m_poolId,
  2418.                                                 " Removed(2) PooledConCtx= ",
  2419.                                                 opoConCtx.pooledConCtx.GetHashCode(),
  2420.                                                 "\n"
  2421.                                             })
  2422.                                         });
  2423.                                     }
  2424.                                     opoConCtx.pooledConCtx.pOpoConValCtx = null;
  2425.                                 }
  2426.                                 OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2427.                                 opoConCtx.m_bOpsConCtxDisposed = true;
  2428.                                 if (opoConCtx.pooledConCtx != null)
  2429.                                 {
  2430.                                     opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2431.                                 }
  2432.                             }
  2433.                         }
  2434.                     }
  2435.                 }
  2436.                 catch (Exception ex5)
  2437.                 {
  2438.                     if (OraTrace.m_TraceLevel != 0u)
  2439.                     {
  2440.                         OraTrace.TraceExceptionInfo(ex5);
  2441.                     }
  2442.                 }
  2443.                 opoConCtx.pooledConCtx = null;
  2444.                 opoConCtx.opsConCtx = IntPtr.Zero;
  2445.                 opoConCtx.opsErrCtx = IntPtr.Zero;
  2446.                 opoConCtx.m_conPooler = null;
  2447.                 opoConCtx.m_udtDescPoolerByName = null;
  2448.                 opoConCtx.m_udtDescPoolerByTDO = null;
  2449.                 opoConCtx.m_systemTransaction = null;
  2450.                 opoConCtx.m_txnType = TxnType.None;
  2451.                 this.UpdateTotalCount(-1, true);
  2452.                 if (this.m_bGridRac)
  2453.                 {
  2454.                     Interlocked.Decrement(ref this.m_cpCtx.m_consFromAppToClear);
  2455.                     if (this.m_cpCtx.m_consFromAppToClear == 0)
  2456.                     {
  2457.                         this.m_bClearPoolInProgress = false;
  2458.                     }
  2459.                 }
  2460.                 else
  2461.                 {
  2462.                     Interlocked.Decrement(ref this.m_consFromAppToClear);
  2463.                     if (this.m_consFromAppToClear == 0)
  2464.                     {
  2465.                         this.m_bClearPoolInProgress = false;
  2466.                     }
  2467.                 }
  2468.             }
  2469.             else
  2470.             {
  2471.                 if (opoConCtx.pooledConCtx != null)
  2472.                 {
  2473.                     if (bDoNotAllocValCtx)
  2474.                     {
  2475.                         opoConCtx.pooledConCtx.pOpoConValCtx = opoConCtx.pOpoConValCtx;
  2476.                         opoConCtx.pOpoConValCtx = null;
  2477.                     }
  2478.                     else
  2479.                     {
  2480.                         num = ConnectionDispenser.CopyPooledConCtx(ref opoConCtx.pooledConCtx.pOpoConValCtx, opoConCtx.pOpoConValCtx);
  2481.                         if (num != 0)
  2482.                         {
  2483.                             try
  2484.                             {
  2485.                                 if (opoConCtx.m_fetchArrayPooler != null)
  2486.                                 {
  2487.                                     opoConCtx.m_fetchArrayPooler.Dispose();
  2488.                                     opoConCtx.m_fetchArrayPooler = null;
  2489.                                 }
  2490.                                 if (!opoConCtx.m_bOpsConCtxDisposed)
  2491.                                 {
  2492.                                     lock (opoConCtx.m_syncObject)
  2493.                                     {
  2494.                                         if (!opoConCtx.m_bOpsConCtxDisposed)
  2495.                                         {
  2496.                                             if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2497.                                             {
  2498.                                                 opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2499.                                                 if (OraTrace.m_TraceLevel != 0u)
  2500.                                                 {
  2501.                                                     OraTrace.Trace(16u, new string[]
  2502.                                                     {
  2503.                                                         string.Concat(new object[]
  2504.                                                         {
  2505.                                                             " (PutConnection) Pool Id = ",
  2506.                                                             opoConCtx.pool.m_poolId,
  2507.                                                             " Removed(3) PooledConCtx= ",
  2508.                                                             opoConCtx.pooledConCtx.GetHashCode(),
  2509.                                                             "\n"
  2510.                                                         })
  2511.                                                     });
  2512.                                                 }
  2513.                                                 opoConCtx.pooledConCtx.pOpoConValCtx = null;
  2514.                                             }
  2515.                                             OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2516.                                             opoConCtx.m_bOpsConCtxDisposed = true;
  2517.                                             if (opoConCtx.pooledConCtx != null)
  2518.                                             {
  2519.                                                 opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2520.                                             }
  2521.                                         }
  2522.                                     }
  2523.                                 }
  2524.                             }
  2525.                             catch (Exception ex6)
  2526.                             {
  2527.                                 if (OraTrace.m_TraceLevel != 0u)
  2528.                                 {
  2529.                                     OraTrace.TraceExceptionInfo(ex6);
  2530.                                 }
  2531.                             }
  2532.                             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  2533.                             {
  2534.                                 ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  2535.                             }
  2536.                             opoConCtx.pooledConCtx = null;
  2537.                             opoConCtx.opsConCtx = IntPtr.Zero;
  2538.                             opoConCtx.opsErrCtx = IntPtr.Zero;
  2539.                             opoConCtx.m_conPooler = null;
  2540.                             opoConCtx.m_udtDescPoolerByName = null;
  2541.                             opoConCtx.m_udtDescPoolerByTDO = null;
  2542.                             opoConCtx.m_systemTransaction = null;
  2543.                             opoConCtx.m_txnType = TxnType.None;
  2544.                             this.UpdateTotalCount(-1, true);
  2545.                             return -1;
  2546.                         }
  2547.                     }
  2548.                     if (opoConCtx.pooledConCtx.pOpoConValCtx->bTAFEnabled == 1)
  2549.                     {
  2550.                         string instanceName = opoConCtx.opoConRefCtx.instanceName;
  2551.                         OpsCon.GetAttributes(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pooledConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2552.                         if (instanceName != opoConCtx.opoConRefCtx.instanceName)
  2553.                         {
  2554.                             OraTrace.Trace(16u, new string[]
  2555.                             {
  2556.                                 string.Concat(new string[]
  2557.                                 {
  2558.                                     " (FO)    Failed over from ",
  2559.                                     instanceName,
  2560.                                     " to ",
  2561.                                     opoConCtx.opoConRefCtx.instanceName,
  2562.                                     "\n"
  2563.                                 })
  2564.                             });
  2565.                             flag2 = true;
  2566.                             if (this.m_clonedCtx.gridCR == 1)
  2567.                             {
  2568.                                 ConnectionPool connectionPool2 = null;
  2569.                                 try
  2570.                                 {
  2571.                                     connectionPool2 = (ConnectionPool)this.m_cpCtx.htInstToCp[instanceName];
  2572.                                 }
  2573.                                 catch
  2574.                                 {
  2575.                                 }
  2576.                                 if (connectionPool2 != null)
  2577.                                 {
  2578.                                     connectionPool2.m_conList.Remove(opoConCtx.pooledConCtx);
  2579.                                     if (OraTrace.m_TraceLevel != 0u)
  2580.                                     {
  2581.                                         OraTrace.Trace(16u, new string[]
  2582.                                         {
  2583.                                             string.Concat(new object[]
  2584.                                             {
  2585.                                                 " (PutConnection) Pool Id = ",
  2586.                                                 opoConCtx.pool.m_poolId,
  2587.                                                 " Removed(6) PooledConCtx= ",
  2588.                                                 opoConCtx.pooledConCtx.GetHashCode(),
  2589.                                                 "\n"
  2590.                                             })
  2591.                                         });
  2592.                                     }
  2593.                                 }
  2594.                             }
  2595.                             connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  2596.                             if (connectionPool == null)
  2597.                             {
  2598.                                 lock (this.m_cpCtx.htInstToCp.SyncRoot)
  2599.                                 {
  2600.                                     connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  2601.                                     if (connectionPool == null)
  2602.                                     {
  2603.                                         connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
  2604.                                         this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
  2605.                                         if (OraTrace.m_TraceLevel != 0u)
  2606.                                         {
  2607.                                             OraTrace.Trace(2u, new string[]
  2608.                                             {
  2609.                                                 string.Concat(new object[]
  2610.                                                 {
  2611.                                                     " (POOL)  New CP created (CP id: ",
  2612.                                                     connectionPool.GetHashCode(),
  2613.                                                     "; CPCtx id: ",
  2614.                                                     connectionPool.m_cpCtx.GetHashCode(),
  2615.                                                     ") for: [Instance=",
  2616.                                                     opoConCtx.opoConRefCtx.instanceName,
  2617.                                                     "]\n"
  2618.                                                 })
  2619.                                             });
  2620.                                             OraTrace.Trace(2u, new string[]
  2621.                                             {
  2622.                                                 string.Concat(new object[]
  2623.                                                 {
  2624.                                                     " (POOL)  Num of Inst CPs in (CPCtx id: ",
  2625.                                                     connectionPool.m_cpCtx.GetHashCode(),
  2626.                                                     ") : ",
  2627.                                                     connectionPool.m_cpCtx.htInstToCp.Count,
  2628.                                                     "\n"
  2629.                                                 })
  2630.                                             });
  2631.                                         }
  2632.                                     }
  2633.                                 }
  2634.                             }
  2635.                             if (connectionPool.m_clonedCtx.gridCR == 1)
  2636.                             {
  2637.                                 if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx))
  2638.                                 {
  2639.                                     connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
  2640.                                 }
  2641.                                 if (OraTrace.m_TraceLevel != 0u)
  2642.                                 {
  2643.                                     OraTrace.Trace(16u, new string[]
  2644.                                     {
  2645.                                         string.Concat(new object[]
  2646.                                         {
  2647.                                             " (PutConnection) Pool Id = ",
  2648.                                             connectionPool.m_poolId,
  2649.                                             " Added(1) PooledConCtx= ",
  2650.                                             opoConCtx.pooledConCtx.GetHashCode(),
  2651.                                             "\n"
  2652.                                         })
  2653.                                     });
  2654.                                 }
  2655.                             }
  2656.                         }
  2657.                     }
  2658.                     opoConCtx.pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
  2659.                     opoConCtx.pooledConCtx.m_conPooler = opoConCtx.m_conPooler;
  2660.                     opoConCtx.pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
  2661.                     opoConCtx.pooledConCtx.m_statementData = opoConCtx.m_statementData;
  2662.                     opoConCtx.pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
  2663.                     if (this.m_bSynchronizeStack)
  2664.                     {
  2665.                         lock (connectionPool.m_connections.SyncRoot)
  2666.                         {
  2667.                             connectionPool.m_connections.Push(opoConCtx.pooledConCtx);
  2668.                             goto IL_11EA;
  2669.                         }
  2670.                     }
  2671.                     connectionPool.m_connections.Push(opoConCtx.pooledConCtx);
  2672.                     IL_11EA:
  2673.                     opoConCtx.pool = connectionPool;
  2674.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  2675.                     {
  2676.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  2677.                     }
  2678.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections && isPopulatePool)
  2679.                     {
  2680.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, opoConCtx);
  2681.                     }
  2682.                     if (this.m_bGridRac && connectionPool.m_cpCtx != null)
  2683.                     {
  2684.                         Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
  2685.                     }
  2686.                     Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
  2687.                     connectionPool.ReleaseSemaphore();
  2688.                     opoConCtx.pooledConCtx = null;
  2689.                     opoConCtx.opsConCtx = IntPtr.Zero;
  2690.                     opoConCtx.opsErrCtx = IntPtr.Zero;
  2691.                     opoConCtx.m_conPooler = null;
  2692.                     opoConCtx.m_udtDescPoolerByName = null;
  2693.                     opoConCtx.m_udtDescPoolerByTDO = null;
  2694.                     if (!flag2)
  2695.                     {
  2696.                         goto IL_1D54;
  2697.                     }
  2698.                     Interlocked.Decrement(ref this.m_counter.total);
  2699.                     Interlocked.Increment(ref connectionPool.m_counter.total);
  2700.                     try
  2701.                     {
  2702.                         if (this.m_encryptedPasswords.m_encryptedPwd != null)
  2703.                         {
  2704.                             opoConCtx.opoConRefCtx.password = this.m_encryptedPasswords.m_encryptedPwd.Password;
  2705.                         }
  2706.                         else
  2707.                         {
  2708.                             opoConCtx.opoConRefCtx.password = "";
  2709.                         }
  2710.                         if (this.m_encryptedPasswords.m_encryptedPxyPwd != null)
  2711.                         {
  2712.                             opoConCtx.opoConRefCtx.proxyPassword = this.m_encryptedPasswords.m_encryptedPxyPwd.Password;
  2713.                         }
  2714.                         else
  2715.                         {
  2716.                             opoConCtx.opoConRefCtx.proxyPassword = "";
  2717.                         }
  2718.                         if ((num = ConnectionDispenser.RegisterCallbacks(opoConCtx)) != 0)
  2719.                         {
  2720.                             OpoConValCtx* ptr = null;
  2721.                             try
  2722.                             {
  2723.                                 if (opoConCtx.m_fetchArrayPooler != null)
  2724.                                 {
  2725.                                     opoConCtx.m_fetchArrayPooler.Dispose();
  2726.                                     opoConCtx.m_fetchArrayPooler = null;
  2727.                                 }
  2728.                                 if (!opoConCtx.m_bOpsConCtxDisposed)
  2729.                                 {
  2730.                                     lock (opoConCtx.m_syncObject)
  2731.                                     {
  2732.                                         if (!opoConCtx.m_bOpsConCtxDisposed)
  2733.                                         {
  2734.                                             if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2735.                                             {
  2736.                                                 opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2737.                                                 if (OraTrace.m_TraceLevel != 0u)
  2738.                                                 {
  2739.                                                     OraTrace.Trace(16u, new string[]
  2740.                                                     {
  2741.                                                         string.Concat(new object[]
  2742.                                                         {
  2743.                                                             " (PutConnection) Pool Id = ",
  2744.                                                             opoConCtx.pool.m_poolId,
  2745.                                                             " Removed(4) PooledConCtx= ",
  2746.                                                             opoConCtx.pooledConCtx.GetHashCode(),
  2747.                                                             "\n"
  2748.                                                         })
  2749.                                                     });
  2750.                                                 }
  2751.                                             }
  2752.                                             OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2753.                                             OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
  2754.                                             opoConCtx.m_bOpsConCtxDisposed = true;
  2755.                                             if (opoConCtx.pooledConCtx != null)
  2756.                                             {
  2757.                                                 opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2758.                                             }
  2759.                                         }
  2760.                                     }
  2761.                                 }
  2762.                             }
  2763.                             catch (Exception ex7)
  2764.                             {
  2765.                                 if (OraTrace.m_TraceLevel != 0u)
  2766.                                 {
  2767.                                     OraTrace.TraceExceptionInfo(ex7);
  2768.                                 }
  2769.                             }
  2770.                             if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  2771.                             {
  2772.                                 ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  2773.                             }
  2774.                             return num;
  2775.                         }
  2776.                         goto IL_1D54;
  2777.                     }
  2778.                     finally
  2779.                     {
  2780.                         opoConCtx.opoConRefCtx.password = null;
  2781.                         opoConCtx.opoConRefCtx.proxyPassword = null;
  2782.                     }
  2783.                 }
  2784.                 PooledConCtx pooledConCtx2 = new PooledConCtx();
  2785.                 pooledConCtx2.opsConCtx = opoConCtx.opsConCtx;
  2786.                 pooledConCtx2.opsErrCtx = opoConCtx.opsErrCtx;
  2787.                 pooledConCtx2.conString = opoConCtx.conString;
  2788.                 pooledConCtx2.creationTime = opoConCtx.creationTime;
  2789.                 pooledConCtx2.m_poolName = opoConCtx.poolName;
  2790.                 pooledConCtx2.m_syncObject = opoConCtx.m_syncObject;
  2791.                 if (bDoNotAllocValCtx)
  2792.                 {
  2793.                     pooledConCtx2.pOpoConValCtx = opoConCtx.pOpoConValCtx;
  2794.                     opoConCtx.pOpoConValCtx = null;
  2795.                 }
  2796.                 else
  2797.                 {
  2798.                     num = ConnectionDispenser.CopyPooledConCtx(ref pooledConCtx2.pOpoConValCtx, opoConCtx.pOpoConValCtx);
  2799.                     if (num != 0)
  2800.                     {
  2801.                         try
  2802.                         {
  2803.                             if (opoConCtx.m_fetchArrayPooler != null)
  2804.                             {
  2805.                                 opoConCtx.m_fetchArrayPooler.Dispose();
  2806.                                 opoConCtx.m_fetchArrayPooler = null;
  2807.                             }
  2808.                             if (!opoConCtx.m_bOpsConCtxDisposed)
  2809.                             {
  2810.                                 lock (opoConCtx.m_syncObject)
  2811.                                 {
  2812.                                     if (!opoConCtx.m_bOpsConCtxDisposed)
  2813.                                     {
  2814.                                         if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
  2815.                                         {
  2816.                                             opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
  2817.                                             if (OraTrace.m_TraceLevel != 0u)
  2818.                                             {
  2819.                                                 OraTrace.Trace(16u, new string[]
  2820.                                                 {
  2821.                                                     string.Concat(new object[]
  2822.                                                     {
  2823.                                                         " (PutConnection) Pool Id = ",
  2824.                                                         opoConCtx.pool.m_poolId,
  2825.                                                         " Removed(5) PooledConCtx= ",
  2826.                                                         opoConCtx.pooledConCtx.GetHashCode(),
  2827.                                                         "\n"
  2828.                                                     })
  2829.                                                 });
  2830.                                             }
  2831.                                             opoConCtx.pooledConCtx.pOpoConValCtx = null;
  2832.                                         }
  2833.                                         OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2834.                                         opoConCtx.m_bOpsConCtxDisposed = true;
  2835.                                         if (opoConCtx.pooledConCtx != null)
  2836.                                         {
  2837.                                             opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
  2838.                                         }
  2839.                                     }
  2840.                                 }
  2841.                             }
  2842.                         }
  2843.                         catch (Exception ex8)
  2844.                         {
  2845.                             if (OraTrace.m_TraceLevel != 0u)
  2846.                             {
  2847.                                 OraTrace.TraceExceptionInfo(ex8);
  2848.                             }
  2849.                         }
  2850.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  2851.                         {
  2852.                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
  2853.                         }
  2854.                         opoConCtx.pooledConCtx = null;
  2855.                         opoConCtx.opsConCtx = IntPtr.Zero;
  2856.                         opoConCtx.opsErrCtx = IntPtr.Zero;
  2857.                         opoConCtx.m_conPooler = null;
  2858.                         opoConCtx.m_udtDescPoolerByName = null;
  2859.                         opoConCtx.m_udtDescPoolerByTDO = null;
  2860.                         opoConCtx.m_systemTransaction = null;
  2861.                         opoConCtx.m_txnType = TxnType.None;
  2862.                         this.UpdateTotalCount(-1, true);
  2863.                         return -1;
  2864.                     }
  2865.                 }
  2866.                 if (pooledConCtx2.pOpoConValCtx->bTAFEnabled == 1)
  2867.                 {
  2868.                     string instanceName2 = opoConCtx.opoConRefCtx.instanceName;
  2869.                     OpsCon.GetAttributes(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, pooledConCtx2.pOpoConValCtx, opoConCtx.opoConRefCtx);
  2870.                     if (instanceName2 != opoConCtx.opoConRefCtx.instanceName)
  2871.                     {
  2872.                         OraTrace.Trace(16u, new string[]
  2873.                         {
  2874.                             string.Concat(new string[]
  2875.                             {
  2876.                                 " (FO)    Failed over from ",
  2877.                                 instanceName2,
  2878.                                 " to ",
  2879.                                 opoConCtx.opoConRefCtx.instanceName,
  2880.                                 "\n"
  2881.                             })
  2882.                         });
  2883.                         flag2 = true;
  2884.                         if (this.m_clonedCtx.gridCR == 1)
  2885.                         {
  2886.                             ConnectionPool connectionPool3 = null;
  2887.                             try
  2888.                             {
  2889.                                 connectionPool3 = (ConnectionPool)this.m_cpCtx.htInstToCp[instanceName2];
  2890.                             }
  2891.                             catch
  2892.                             {
  2893.                             }
  2894.                             if (connectionPool3 != null)
  2895.                             {
  2896.                                 connectionPool3.m_conList.Remove(opoConCtx.pooledConCtx);
  2897.                                 if (OraTrace.m_TraceLevel != 0u)
  2898.                                 {
  2899.                                     OraTrace.Trace(16u, new string[]
  2900.                                     {
  2901.                                         string.Concat(new object[]
  2902.                                         {
  2903.                                             " (PutConnection) Pool Id = ",
  2904.                                             opoConCtx.pool.m_poolId,
  2905.                                             " Removed(6) PooledConCtx= ",
  2906.                                             opoConCtx.pooledConCtx.GetHashCode(),
  2907.                                             "\n"
  2908.                                         })
  2909.                                     });
  2910.                                 }
  2911.                             }
  2912.                         }
  2913.                         connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  2914.                         if (connectionPool == null)
  2915.                         {
  2916.                             lock (this.m_cpCtx.htInstToCp.SyncRoot)
  2917.                             {
  2918.                                 connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
  2919.                                 if (connectionPool == null)
  2920.                                 {
  2921.                                     connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
  2922.                                     this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
  2923.                                     if (OraTrace.m_TraceLevel != 0u)
  2924.                                     {
  2925.                                         OraTrace.Trace(2u, new string[]
  2926.                                         {
  2927.                                             string.Concat(new object[]
  2928.                                             {
  2929.                                                 " (POOL)  New CP created (CP id: ",
  2930.                                                 connectionPool.GetHashCode(),
  2931.                                                 "; CPCtx id: ",
  2932.                                                 connectionPool.m_cpCtx.GetHashCode(),
  2933.                                                 ") for: [Instance=",
  2934.                                                 opoConCtx.opoConRefCtx.instanceName,
  2935.                                                 "]\n"
  2936.                                             })
  2937.                                         });
  2938.                                         OraTrace.Trace(2u, new string[]
  2939.                                         {
  2940.                                             string.Concat(new object[]
  2941.                                             {
  2942.                                                 " (POOL)  Num of Inst CPs in (CPCtx id: ",
  2943.                                                 connectionPool.m_cpCtx.GetHashCode(),
  2944.                                                 ") : ",
  2945.                                                 connectionPool.m_cpCtx.htInstToCp.Count,
  2946.                                                 "\n"
  2947.                                             })
  2948.                                         });
  2949.                                     }
  2950.                                 }
  2951.                                 goto IL_1A7F;
  2952.                             }
  2953.                         }
  2954.                         opoConCtx.pool = connectionPool;
  2955.                         IL_1A7F:
  2956.                         if (connectionPool.m_clonedCtx.gridCR == 1)
  2957.                         {
  2958.                             if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx))
  2959.                             {
  2960.                                 connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
  2961.                             }
  2962.                             if (OraTrace.m_TraceLevel != 0u)
  2963.                             {
  2964.                                 OraTrace.Trace(16u, new string[]
  2965.                                 {
  2966.                                     string.Concat(new object[]
  2967.                                     {
  2968.                                         " (PutConnection) Pool Id = ",
  2969.                                         connectionPool.m_poolId,
  2970.                                         " Added(2) PooledConCtx= ",
  2971.                                         opoConCtx.pooledConCtx.GetHashCode(),
  2972.                                         "\n"
  2973.                                     })
  2974.                                 });
  2975.                             }
  2976.                         }
  2977.                     }
  2978.                 }
  2979.                 pooledConCtx2.opoConRefCtx = new OpoConRefCtx();
  2980.                 pooledConCtx2.opoConRefCtx.serverVersion = opoConCtx.opoConRefCtx.serverVersion;
  2981.                 pooledConCtx2.opoConRefCtx.dataSource = opoConCtx.opoConRefCtx.dataSource;
  2982.                 pooledConCtx2.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
  2983.                 pooledConCtx2.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
  2984.                 pooledConCtx2.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
  2985.                 pooledConCtx2.opoConRefCtx.instanceName = opoConCtx.opoConRefCtx.instanceName;
  2986.                 pooledConCtx2.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
  2987.                 pooledConCtx2.opoConRefCtx.proxyUserId = opoConCtx.opoConRefCtx.proxyUserId;
  2988.                 pooledConCtx2.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
  2989.                 pooledConCtx2.opoConRefCtx.ttOpsConOpenErrMssg = opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
  2990.                 pooledConCtx2.m_conPooler = opoConCtx.m_conPooler;
  2991.                 pooledConCtx2.m_udtDescPoolerByName = opoConCtx.m_udtDescPoolerByName;
  2992.                 pooledConCtx2.m_udtDescPoolerByTDO = opoConCtx.m_udtDescPoolerByTDO;
  2993.                 pooledConCtx2.m_txnid = opoConCtx.m_txnid;
  2994.                 pooledConCtx2.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
  2995.                 pooledConCtx2.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
  2996.                 pooledConCtx2.m_statementData = opoConCtx.m_statementData;
  2997.                 pooledConCtx2.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
  2998.                 if (this.m_bSynchronizeStack)
  2999.                 {
  3000.                     lock (connectionPool.m_connections.SyncRoot)
  3001.                     {
  3002.                         connectionPool.m_connections.Push(pooledConCtx2);
  3003.                         goto IL_1CD5;
  3004.                     }
  3005.                 }
  3006.                 connectionPool.m_connections.Push(pooledConCtx2);
  3007.                 IL_1CD5:
  3008.                 opoConCtx.pool = connectionPool;
  3009.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  3010.                 {
  3011.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
  3012.                 }
  3013.                 if (isPopulatePool && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  3014.                 {
  3015.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, opoConCtx);
  3016.                 }
  3017.                 bool bGridRac = opoConCtx.bGridRac;
  3018.                 if (bGridRac && connectionPool.m_cpCtx != null)
  3019.                 {
  3020.                     Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
  3021.                 }
  3022.                 Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
  3023.                 connectionPool.ReleaseSemaphore();
  3024.             }
  3025.             IL_1D54:
  3026.             opoConCtx.opsConCtx = IntPtr.Zero;
  3027.             opoConCtx.opsErrCtx = IntPtr.Zero;
  3028.             opoConCtx.m_conPooler = null;
  3029.             opoConCtx.m_udtDescPoolerByName = null;
  3030.             opoConCtx.m_udtDescPoolerByTDO = null;
  3031.             opoConCtx.m_systemTransaction = null;
  3032.             opoConCtx.m_txnType = TxnType.None;
  3033.             if (flag2)
  3034.             {
  3035.                 Interlocked.Decrement(ref this.m_counter.total);
  3036.                 Interlocked.Increment(ref connectionPool.m_counter.total);
  3037.             }
  3038.             if ((opoConCtx.bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0)
  3039.             {
  3040.                 if (!this.m_inactive)
  3041.                 {
  3042.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  3043.                     {
  3044.                         ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  3045.                     }
  3046.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  3047.                     {
  3048.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  3049.                     }
  3050.                     this.m_inactive = true;
  3051.                 }
  3052.             }
  3053.             else
  3054.             {
  3055.                 if (this.m_inactive)
  3056.                 {
  3057.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  3058.                     {
  3059.                         ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  3060.                     }
  3061.                     if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  3062.                     {
  3063.                         ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  3064.                     }
  3065.                     this.m_inactive = false;
  3066.                 }
  3067.             }
  3068.             return num;
  3069.         }
  3070.         public unsafe void TransactionEnd(object obj)
  3071.         {
  3072.             int num = 0;
  3073.             PooledConCtx pooledConCtx = (PooledConCtx)obj;
  3074.             if (OraTrace.m_TraceLevel != 0u)
  3075.             {
  3076.                 OraTrace.Trace(4u, new string[]
  3077.                 {
  3078.                     " (MTS) ConnectionPool::TransactionEnd() txnid: (" + pooledConCtx.m_txnid + ")\n"
  3079.                 });
  3080.             }
  3081.             if (this.m_cpCtx != null && pooledConCtx.m_txnid != null)
  3082.             {
  3083.                 this.m_cpCtx.m_htTxnIdToIntance.Remove(pooledConCtx.m_txnid);
  3084.             }
  3085.             pooledConCtx.m_txnid = null;
  3086.             if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  3087.             {
  3088.                 ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
  3089.             }
  3090.             if (pooledConCtx != null && pooledConCtx.m_promotableTxnManager != null)
  3091.             {
  3092.                 if (pooledConCtx.m_promotableTxnManager.m_bLocalTxnPromoted)
  3093.                 {
  3094.                     try
  3095.                     {
  3096.                         OpsCon.DelistPromotedTxn(pooledConCtx.opsConCtx);
  3097.                     }
  3098.                     catch (Exception ex)
  3099.                     {
  3100.                         if (OraTrace.m_TraceLevel != 0u)
  3101.                         {
  3102.                             OraTrace.TraceExceptionInfo(ex);
  3103.                         }
  3104.                     }
  3105.                 }
  3106.                 string localTxnIdentifier = pooledConCtx.m_promotableTxnManager.m_localTxnIdentifier;
  3107.                 if (!string.IsNullOrEmpty(localTxnIdentifier))
  3108.                 {
  3109.                     OracleConnection.m_pspePrimaryResourceEntry.Remove(localTxnIdentifier);
  3110.                     pooledConCtx.m_promotableTxnManager = null;
  3111.                 }
  3112.             }
  3113.             else
  3114.             {
  3115.                 pooledConCtx.opoConRefCtx.pITransaction = null;
  3116.                 try
  3117.                 {
  3118.                     num = OpsCon.Enlist(pooledConCtx.opsConCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  3119.                 }
  3120.                 catch (Exception ex2)
  3121.                 {
  3122.                     if (OraTrace.m_TraceLevel != 0u)
  3123.                     {
  3124.                         OraTrace.TraceExceptionInfo(ex2);
  3125.                     }
  3126.                     num = ErrRes.INT_ERR;
  3127.                 }
  3128.                 finally
  3129.                 {
  3130.                     if (num != 0)
  3131.                     {
  3132.                         if (OraTrace.m_TraceLevel != 0u)
  3133.                         {
  3134.                             OraTrace.Trace(4u, new string[]
  3135.                             {
  3136.                                 " (MTS)  ConnectionPool::TransactionEnd(): delistment failure txnid:" + pooledConCtx.m_txnid + "\n"
  3137.                             });
  3138.                         }
  3139.                         try
  3140.                         {
  3141.                             if (pooledConCtx.m_fetchArrayPooler != null)
  3142.                             {
  3143.                                 pooledConCtx.m_fetchArrayPooler.Dispose();
  3144.                                 pooledConCtx.m_fetchArrayPooler = null;
  3145.                             }
  3146.                             if (!pooledConCtx.m_bOpsConCtxDisposed)
  3147.                             {
  3148.                                 lock (pooledConCtx.m_syncObject)
  3149.                                 {
  3150.                                     if (!pooledConCtx.m_bOpsConCtxDisposed)
  3151.                                     {
  3152.                                         if (this.m_clonedCtx.gridCR == 1)
  3153.                                         {
  3154.                                             this.m_conList.Remove(pooledConCtx);
  3155.                                             if (OraTrace.m_TraceLevel != 0u)
  3156.                                             {
  3157.                                                 OraTrace.Trace(16u, new string[]
  3158.                                                 {
  3159.                                                     string.Concat(new object[]
  3160.                                                     {
  3161.                                                         " (TransactionEnd) Pool Id = ",
  3162.                                                         this.m_poolId,
  3163.                                                         " Removed PooledConCtx= ",
  3164.                                                         pooledConCtx.GetHashCode(),
  3165.                                                         "\n"
  3166.                                                     })
  3167.                                                 });
  3168.                                             }
  3169.                                         }
  3170.                                         OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  3171.                                         pooledConCtx.m_bOpsConCtxDisposed = true;
  3172.                                     }
  3173.                                 }
  3174.                             }
  3175.                         }
  3176.                         catch (Exception ex3)
  3177.                         {
  3178.                             if (OraTrace.m_TraceLevel != 0u)
  3179.                             {
  3180.                                 OraTrace.TraceExceptionInfo(ex3);
  3181.                             }
  3182.                         }
  3183.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  3184.                         {
  3185.                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
  3186.                         }
  3187.                         this.UpdateTotalCount(-1, true);
  3188.                     }
  3189.                 }
  3190.                 if (num != 0)
  3191.                 {
  3192.                     return;
  3193.                 }
  3194.             }
  3195.             if ((pooledConCtx.opoConRefCtx.proxyUserId != null && pooledConCtx.opoConRefCtx.proxyUserId.Length > 0) || pooledConCtx.pOpoConValCtx->OSAuthent == 2)
  3196.             {
  3197.                 OpsCon.CloseProxyAuthUserSession(pooledConCtx.opsConCtx, pooledConCtx.opsErrCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  3198.             }
  3199.             OpoConCtx opoConCtx = new OpoConCtx();
  3200.             opoConCtx.pooledConCtx = pooledConCtx;
  3201.             opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
  3202.             opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
  3203.             opoConCtx.pOpoConValCtx = pooledConCtx.pOpoConValCtx;
  3204.             opoConCtx.poolName = pooledConCtx.m_poolName;
  3205.             opoConCtx.opoConRefCtx = new OpoConRefCtx();
  3206.             opoConCtx.opoConRefCtx.serverVersion = pooledConCtx.opoConRefCtx.serverVersion;
  3207.             opoConCtx.opoConRefCtx.dataSource = pooledConCtx.opoConRefCtx.dataSource;
  3208.             opoConCtx.opoConRefCtx.dbName = pooledConCtx.opoConRefCtx.dbName;
  3209.             opoConCtx.opoConRefCtx.hostName = pooledConCtx.opoConRefCtx.hostName;
  3210.             opoConCtx.opoConRefCtx.serviceName = pooledConCtx.opoConRefCtx.serviceName;
  3211.             opoConCtx.opoConRefCtx.instanceName = pooledConCtx.opoConRefCtx.instanceName;
  3212.             opoConCtx.opoConRefCtx.dbDomainName = pooledConCtx.opoConRefCtx.dbDomainName;
  3213.             opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg = pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
  3214.             opoConCtx.m_conPooler = pooledConCtx.m_conPooler;
  3215.             opoConCtx.m_udtDescPoolerByName = pooledConCtx.m_udtDescPoolerByName;
  3216.             opoConCtx.m_udtDescPoolerByTDO = pooledConCtx.m_udtDescPoolerByTDO;
  3217.             opoConCtx.m_txnid = pooledConCtx.m_txnid;
  3218.             opoConCtx.m_systemTransaction = null;
  3219.             opoConCtx.m_txnType = TxnType.None;
  3220.             opoConCtx.m_promotableTxnManager = null;
  3221.             opoConCtx.pooledConCtx.m_promotableTxnManager = null;
  3222.             opoConCtx.m_fetchArrayPooler = pooledConCtx.m_fetchArrayPooler;
  3223.             opoConCtx.m_statementData = pooledConCtx.m_statementData;
  3224.             opoConCtx.m_totalDataAvailable = pooledConCtx.m_totalDataAvailable;
  3225.             if (this.m_bSynchronizeStack)
  3226.             {
  3227.                 lock (this.m_connections)
  3228.                 {
  3229.                     this.PutConnection(ref opoConCtx, true, false, false, 1, false, true);
  3230.                     goto IL_4A9;
  3231.                 }
  3232.             }
  3233.             this.PutConnection(ref opoConCtx, true, false, false, 1, false, true);
  3234.             IL_4A9:
  3235.             opoConCtx = null;
  3236.         }
  3237.         public void ClearPool(bool bInvalidOnly, bool bRefresh)
  3238.         {
  3239.             int num = 0;
  3240.             int num2 = 0;
  3241.             Stack stack = null;
  3242.             int num3 = 0;
  3243.             Thread.Sleep(100);
  3244.             this.m_bSynchronizeStack = true;
  3245.             this.m_bClearPoolInProgress = true;
  3246.             try
  3247.             {
  3248.                 lock (this.m_connections)
  3249.                 {
  3250.                     if (bInvalidOnly)
  3251.                     {
  3252.                         stack = Stack.Synchronized(new Stack());
  3253.                     }
  3254.                     else
  3255.                     {
  3256.                         this.m_clearRequestTimeStamp = DateTime.Now;
  3257.                     }
  3258.                     while (this.m_connections.Count > 0)
  3259.                     {
  3260.                         int num4 = 0;
  3261.                         if (this.m_bGridRac && this.m_cpCtx != null)
  3262.                         {
  3263.                             try
  3264.                             {
  3265.                                 num4 = OpsCon.WaitForSingleObject(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 0);
  3266.                             }
  3267.                             catch (Exception ex)
  3268.                             {
  3269.                                 if (OraTrace.m_TraceLevel != 0u)
  3270.                                 {
  3271.                                     OraTrace.TraceExceptionInfo(ex);
  3272.                                 }
  3273.                                 num4 = -1;
  3274.                             }
  3275.                             if (num4 != 0)
  3276.                             {
  3277.                                 break;
  3278.                             }
  3279.                             Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
  3280.                         }
  3281.                         int num5 = 0;
  3282.                         try
  3283.                         {
  3284.                             num5 = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, 0);
  3285.                         }
  3286.                         catch (Exception ex2)
  3287.                         {
  3288.                             if (OraTrace.m_TraceLevel != 0u)
  3289.                             {
  3290.                                 OraTrace.TraceExceptionInfo(ex2);
  3291.                             }
  3292.                             num5 = -1;
  3293.                         }
  3294.                         if (num5 == 0)
  3295.                         {
  3296.                             Interlocked.Decrement(ref this.m_counter.totalAvailable);
  3297.                             PooledConCtx pooledConCtx = (PooledConCtx)this.m_connections.Pop();
  3298.                             if (pooledConCtx != null)
  3299.                             {
  3300.                                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  3301.                                 {
  3302.                                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
  3303.                                 }
  3304.                                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  3305.                                 {
  3306.                                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
  3307.                                 }
  3308.                             }
  3309.                             try
  3310.                             {
  3311.                                 if (bInvalidOnly)
  3312.                                 {
  3313.                                     OpsCon.CheckConStatus(pooledConCtx.opsConCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opsErrCtx, 0, ref num2, 1, 1);
  3314.                                 }
  3315.                             }
  3316.                             catch (Exception ex3)
  3317.                             {
  3318.                                 if (OraTrace.m_TraceLevel != 0u)
  3319.                                 {
  3320.                                     OraTrace.TraceExceptionInfo(ex3);
  3321.                                 }
  3322.                                 num2 = 0;
  3323.                             }
  3324.                             finally
  3325.                             {
  3326.                                 if (num2 == 0)
  3327.                                 {
  3328.                                     try
  3329.                                     {
  3330.                                         try
  3331.                                         {
  3332.                                             if (pooledConCtx.m_fetchArrayPooler != null)
  3333.                                             {
  3334.                                                 pooledConCtx.m_fetchArrayPooler.Dispose();
  3335.                                                 pooledConCtx.m_fetchArrayPooler = null;
  3336.                                             }
  3337.                                             if (!pooledConCtx.m_bOpsConCtxDisposed)
  3338.                                             {
  3339.                                                 lock (pooledConCtx.m_syncObject)
  3340.                                                 {
  3341.                                                     if (!pooledConCtx.m_bOpsConCtxDisposed)
  3342.                                                     {
  3343.                                                         if (this.m_clonedCtx.gridCR == 1)
  3344.                                                         {
  3345.                                                             this.m_conList.Remove(pooledConCtx);
  3346.                                                             if (OraTrace.m_TraceLevel != 0u)
  3347.                                                             {
  3348.                                                                 OraTrace.Trace(16u, new string[]
  3349.                                                                 {
  3350.                                                                     string.Concat(new object[]
  3351.                                                                     {
  3352.                                                                         " (ClearPool) Pool Id = ",
  3353.                                                                         this.m_poolId,
  3354.                                                                         " Removed PooledConCtx= ",
  3355.                                                                         pooledConCtx.GetHashCode(),
  3356.                                                                         "\n"
  3357.                                                                     })
  3358.                                                                 });
  3359.                                                             }
  3360.                                                         }
  3361.                                                         OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
  3362.                                                         pooledConCtx.m_bOpsConCtxDisposed = true;
  3363.                                                     }
  3364.                                                 }
  3365.                                             }
  3366.                                         }
  3367.                                         catch (Exception ex4)
  3368.                                         {
  3369.                                             if (OraTrace.m_TraceLevel != 0u)
  3370.                                             {
  3371.                                                 OraTrace.TraceExceptionInfo(ex4);
  3372.                                             }
  3373.                                         }
  3374.                                         continue;
  3375.                                     }
  3376.                                     finally
  3377.                                     {
  3378.                                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
  3379.                                         {
  3380.                                             ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
  3381.                                         }
  3382.                                         pooledConCtx.opsConCtx = IntPtr.Zero;
  3383.                                         pooledConCtx.opsErrCtx = IntPtr.Zero;
  3384.                                         pooledConCtx.pOpoConValCtx = null;
  3385.                                         pooledConCtx.m_conPooler = null;
  3386.                                         pooledConCtx.m_udtDescPoolerByName = null;
  3387.                                         pooledConCtx.m_udtDescPoolerByTDO = null;
  3388.                                         this.UpdateTotalCount(-1, true);
  3389.                                         num++;
  3390.                                     }
  3391.                                 }
  3392.                                 stack.Push(pooledConCtx);
  3393.                             }
  3394.                         }
  3395.                         else
  3396.                         {
  3397.                             if (num4 == 0 && this.m_bGridRac && this.m_cpCtx != null)
  3398.                             {
  3399.                                 try
  3400.                                 {
  3401.                                     OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num3);
  3402.                                 }
  3403.                                 catch (Exception ex5)
  3404.                                 {
  3405.                                     if (OraTrace.m_TraceLevel != 0u)
  3406.                                     {
  3407.                                         OraTrace.TraceExceptionInfo(ex5);
  3408.                                     }
  3409.                                 }
  3410.                                 Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
  3411.                                 break;
  3412.                             }
  3413.                             break;
  3414.                         }
  3415.                     }
  3416.                     if (stack != null && stack.Count > 0)
  3417.                     {
  3418.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
  3419.                         {
  3420.                             ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfFreeConnections, stack.Count - this.m_connections.Count, this.m_clonedCtx);
  3421.                         }
  3422.                         if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
  3423.                         {
  3424.                             ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfPooledConnections, stack.Count - this.m_connections.Count, this.m_clonedCtx);
  3425.                         }
  3426.                         this.m_connections = stack;
  3427.                         for (int i = 0; i < stack.Count; i++)
  3428.                         {
  3429.                             if (this.m_bGridRac && this.m_cpCtx != null)
  3430.                             {
  3431.                                 Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
  3432.                             }
  3433.                             Interlocked.Increment(ref this.m_counter.totalAvailable);
  3434.                             this.ReleaseSemaphore();
  3435.                         }
  3436.                     }
  3437.                     if (this.m_bGridRac)
  3438.                     {
  3439.                         Interlocked.Add(ref this.m_cpCtx.m_consFromAppToClear, this.m_cpCtx.m_counter.total);
  3440.                     }
  3441.                     else
  3442.                     {
  3443.                         Interlocked.Add(ref this.m_consFromAppToClear, this.m_counter.total);
  3444.                     }
  3445.                 }
  3446.             }
  3447.             finally
  3448.             {
  3449.                 this.m_bSynchronizeStack = false;
  3450.             }
  3451.             if ((this.m_bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0 && !this.m_inactive)
  3452.             {
  3453.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
  3454.                 {
  3455.                     ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
  3456.                 }
  3457.                 if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
  3458.                 {
  3459.                     ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
  3460.                 }
  3461.                 this.m_inactive = true;
  3462.             }
  3463.         }
  3464.         private void PushToResourcePool(OpoConCtx opoConCtx, PooledConCtx pooledConCtx)
  3465.         {
  3466.             pooledConCtx.m_txnid = opoConCtx.m_txnid;
  3467.             this.m_oraResPool.PutResource(opoConCtx.m_systemTransaction, pooledConCtx);
  3468.             opoConCtx.m_systemTransaction = null;
  3469.             opoConCtx.m_txnType = TxnType.None;
  3470.         }
  3471.         private void UpdateAgentRecommendations(OracleTuningAgent.RecommendationType recommendationType, object recommendation)
  3472.         {
  3473.             try
  3474.             {
  3475.                 if (recommendationType == OracleTuningAgent.RecommendationType.SCS)
  3476.                 {
  3477.                     this.m_scsRecommendations = (int)recommendation;
  3478.                     if (OraTrace.m_TraceLevel != 0u)
  3479.                     {
  3480.                         OraTrace.Trace(64u, new string[]
  3481.                         {
  3482.                             string.Concat(new object[]
  3483.                             {
  3484.                                 " (TUNING) ConnectionPool::UpdateAgentRecommendations(): SCS recommendations for pool with Id: ",
  3485.                                 this.m_poolId,
  3486.                                 "; Change to ",
  3487.                                 this.m_scsRecommendations.ToString(),
  3488.                                 " \n"
  3489.                             })
  3490.                         });
  3491.                     }
  3492.                 }
  3493.             }
  3494.             catch (Exception ex)
  3495.             {
  3496.                 if (OraTrace.m_TraceLevel != 0u)
  3497.                 {
  3498.                     OraTrace.Trace(64u, new string[]
  3499.                     {
  3500.                         string.Concat(new object[]
  3501.                         {
  3502.                             " (ERROR) ConnectionPool::UpdateAgentRecommendations(): Pool Id: ",
  3503.                             this.m_poolId,
  3504.                             "; Exception: ",
  3505.                             ex.ToString(),
  3506.                             " \n"
  3507.                         })
  3508.                     });
  3509.                 }
  3510.             }
  3511.         }
  3512.         private void IncrementStmtSamplesLimit()
  3513.         {
  3514.             this.m_stmtSamplesLimit += 100;
  3515.         }
  3516.     }
  3517. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement