Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.EnterpriseServices;
- using System.Security.Principal;
- using System.Threading;
- using System.Transactions;
- namespace Oracle.DataAccess.Client
- {
- internal class ConnectionPool
- {
- internal const int DEFAULT_STMT_CACHE_SIZE_WITH_SELF_TUNING = 30;
- public const int WAIT_ABAONDONED = 128;
- public const int WAIT_OBJECT_0 = 0;
- public const int WAIT_TIMEOUT = 258;
- public const int WAIT_FAILED = -1;
- internal int m_agentKey = -1;
- internal int m_poolId = -1;
- internal int m_scsRecommendations = 30;
- internal int m_stmtSamplesLimit;
- public Stack m_connections;
- public ResourcePool m_mtsConnections;
- public OracleResourcePool m_oraResPool;
- public IntPtr m_semAvaNumOfCons;
- public Timer m_timer;
- public OpoConCtx m_clonedCtx;
- public Counter m_counter;
- private bool m_skipDecrement;
- public CPCtx m_cpCtx;
- public int m_rlbGravCounter;
- public float m_attemptedRequests;
- public bool m_bSynchronizeStack;
- public bool m_bClearPoolInProgress;
- public int m_consFromAppToClear;
- public bool m_bGridRac;
- public EncryptedPasswords m_encryptedPasswords;
- internal bool m_inactive;
- private OraclePerfCounter[] m_perfCounterRefs;
- internal object m_populationSyncObj;
- public DateTime m_clearRequestTimeStamp;
- private WindowsIdentity m_identity;
- public ArrayList m_conList = ArrayList.Synchronized(new ArrayList());
- internal bool HasValidConnections
- {
- get
- {
- return this.m_conList.Count > 0;
- }
- }
- public ConnectionPool(OpoConCtx opoConCtx, CPCtx cpCtx) : this(opoConCtx, cpCtx, null)
- {
- }
- public unsafe ConnectionPool(OpoConCtx opoConCtx, CPCtx cpCtx, WindowsIdentity identity)
- {
- try
- {
- this.m_populationSyncObj = new object();
- this.m_poolId = opoConCtx.conString.GetHashCode();
- if (opoConCtx.m_bSelfTuning)
- {
- this.m_stmtSamplesLimit = 1000;
- OracleTuningAgent.Register(opoConCtx.conString, opoConCtx.poolName, this.m_poolId, new OracleTuningAgent.UpdateRecommendations(this.UpdateAgentRecommendations), new OracleTuningAgent.IncrementStmtSamplesLimit(this.IncrementStmtSamplesLimit), out this.m_agentKey);
- if (-1 == this.m_agentKey)
- {
- opoConCtx.m_bSelfTuning = false;
- }
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(64u, new string[]
- {
- string.Concat(new string[]
- {
- "(ERROR) ConnectionPool::ConnectionPool(): Pool ",
- opoConCtx.conString,
- "; Exception: ",
- ex.ToString(),
- " \n"
- })
- });
- }
- }
- this.m_scsRecommendations = opoConCtx.pOpoConValCtx->StmtCacheSize;
- if (OraTrace.m_PerformanceCounters != PerfCounterLevel.None)
- {
- this.m_perfCounterRefs = new OraclePerfCounter[12];
- }
- this.m_connections = Stack.Synchronized(new Stack(opoConCtx.minPoolSize));
- this.m_cpCtx = cpCtx;
- if (Environment.OSVersion.Version.Major <= 4)
- {
- opoConCtx.pOpoConValCtx->Enlist = 0;
- }
- else
- {
- this.m_oraResPool = new OracleResourcePool(new OracleResourcePool.TransactionEndDelegate(this.TransactionEnd));
- this.m_mtsConnections = new ResourcePool(new ResourcePool.TransactionEndDelegate(this.TransactionEnd));
- }
- try
- {
- this.m_semAvaNumOfCons = OpsCon.CreateSemaphore(IntPtr.Zero, 0, opoConCtx.maxPoolSize, "");
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- throw;
- }
- this.m_identity = null;
- try
- {
- if (opoConCtx.pOpoConValCtx->OSAuthent == 1 || opoConCtx.pOpoConValCtx->OSAuthent == 2)
- {
- if (identity != null)
- {
- this.m_identity = identity;
- }
- else
- {
- this.m_identity = WindowsIdentity.GetCurrent();
- }
- }
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new string[]
- {
- " (POOL) (ERROR) ConnectionPool::ConnectionPool(): Pool: ",
- opoConCtx.poolName,
- "; Exception: ",
- ex3.ToString(),
- " \n"
- })
- });
- }
- }
- this.m_clonedCtx = (OpoConCtx)opoConCtx.Clone();
- this.m_clonedCtx.pool = this;
- opoConCtx.pool = this;
- this.m_encryptedPasswords = new EncryptedPasswords(opoConCtx);
- this.m_clonedCtx.opoConRefCtx.password = null;
- this.m_clonedCtx.opoConRefCtx.proxyPassword = null;
- this.m_bGridRac = this.m_clonedCtx.bGridRac;
- this.m_clonedCtx.pOpoConValCtx->Pooling = (*opoConCtx.pOpoConValCtx).Pooling;
- this.m_clonedCtx.pOpoConValCtx->DBAPrivilege = (*opoConCtx.pOpoConValCtx).DBAPrivilege;
- this.m_clonedCtx.pOpoConValCtx->SetIntAndExtName = (*opoConCtx.pOpoConValCtx).SetIntAndExtName;
- if (this.m_cpCtx == null)
- {
- this.m_timer = new Timer(new TimerCallback(this.RegulateNumOfConsThreadFunc), null, opoConCtx.poolRegulator * 1000, opoConCtx.poolRegulator * 1000);
- }
- this.m_counter = new Counter(false);
- this.m_skipDecrement = true;
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- }
- ~ConnectionPool()
- {
- this.Dispose();
- }
- private void Dispose()
- {
- try
- {
- if (this.m_agentKey != -1)
- {
- OracleTuningAgent.Unregister(this.m_agentKey);
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(64u, new string[]
- {
- string.Concat(new object[]
- {
- "(ERROR) ConnectionPool::Dispose(): Pool Id: ",
- this.m_poolId,
- "; Exception: ",
- ex.ToString(),
- " \n"
- })
- });
- }
- }
- try
- {
- if (this.m_semAvaNumOfCons != IntPtr.Zero)
- {
- try
- {
- OpsCon.CloseHandle(this.m_semAvaNumOfCons);
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- this.m_semAvaNumOfCons = IntPtr.Zero;
- }
- this.m_encryptedPasswords.Dispose();
- if (this.m_clonedCtx != null && this.m_clonedCtx.pOpoConValCtx != null)
- {
- try
- {
- OpsCon.FreeValCtx(ref this.m_clonedCtx.pOpoConValCtx);
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- }
- }
- int count = this.m_connections.Count;
- while (this.m_connections.Count > 0)
- {
- PooledConCtx pooledConCtx = null;
- bool flag = this.m_cpCtx != null;
- if (flag)
- {
- Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
- }
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections.SyncRoot)
- {
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- goto IL_181;
- }
- goto IL_16F;
- }
- goto IL_16F;
- IL_181:
- pooledConCtx.m_conPooler = null;
- pooledConCtx.m_udtDescPoolerByName = null;
- pooledConCtx.m_udtDescPoolerByTDO = null;
- try
- {
- if (pooledConCtx.m_fetchArrayPooler != null)
- {
- pooledConCtx.m_fetchArrayPooler.Dispose();
- pooledConCtx.m_fetchArrayPooler = null;
- }
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- lock (pooledConCtx.m_syncObject)
- {
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- if (this.m_clonedCtx.gridCR == 1)
- {
- this.m_conList.Remove(pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (ConnectionPool's Dispose) Pool Id = ",
- this.m_poolId,
- " Removed PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- catch (Exception ex4)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex4);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
- continue;
- }
- continue;
- IL_16F:
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- goto IL_181;
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfFreeConnections, -1 * count, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfPooledConnections, -1 * count, this.m_clonedCtx);
- }
- }
- catch
- {
- }
- if (this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- }
- else
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- }
- GC.SuppressFinalize(this);
- }
- public unsafe void PopulatePool(object state)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- " (POOL) (ENTRY) ConnectionPool::PopulatePool(): Pool (id: " + this.m_clonedCtx.conString.GetHashCode() + ");\n"
- });
- }
- int num = 0;
- int num2 = (int)state;
- int num3 = 0;
- int num4 = 0;
- WindowsImpersonationContext windowsImpersonationContext = null;
- try
- {
- if (OraTrace.m_CPThreadPrioritization == 1)
- {
- Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
- }
- }
- catch
- {
- OraTrace.m_CPThreadPrioritization = 0;
- }
- try
- {
- if (this.m_identity != null)
- {
- try
- {
- if (WindowsIdentity.GetCurrent() != this.m_identity)
- {
- windowsImpersonationContext = this.m_identity.Impersonate();
- }
- }
- catch (Exception ex)
- {
- windowsImpersonationContext = null;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) (ERROR) ConnectionPool::PopulatePool(): Pool (id: ",
- this.m_clonedCtx.conString.GetHashCode(),
- "); Exception: ",
- ex.ToString(),
- " \n"
- })
- });
- }
- throw;
- }
- }
- ConnectionPool connectionPool = this;
- int num5 = 0;
- 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))
- {
- lock (this.m_populationSyncObj)
- {
- for (int i = 0; i < num2; i++)
- {
- if (this.m_bGridRac)
- {
- if (this.m_cpCtx.m_counter.total >= this.m_clonedCtx.maxPoolSize)
- {
- break;
- }
- }
- else
- {
- if (this.m_counter.total >= this.m_clonedCtx.maxPoolSize)
- {
- break;
- }
- }
- OpoConCtx opoConCtx = (OpoConCtx)this.m_clonedCtx.Clone();
- try
- {
- if (this.m_encryptedPasswords.m_encryptedPwd != null)
- {
- opoConCtx.opoConRefCtx.password = this.m_encryptedPasswords.m_encryptedPwd.Password;
- }
- else
- {
- opoConCtx.opoConRefCtx.password = "";
- }
- if (this.m_encryptedPasswords.m_encryptedPxyPwd != null)
- {
- opoConCtx.opoConRefCtx.proxyPassword = this.m_encryptedPasswords.m_encryptedPxyPwd.Password;
- }
- else
- {
- opoConCtx.opoConRefCtx.proxyPassword = "";
- }
- if (opoConCtx.m_bSelfTuning)
- {
- opoConCtx.pOpoConValCtx->StmtCacheSize = this.m_scsRecommendations;
- if (opoConCtx.pOpoConValCtx->StmtCacheSize > OraTrace.MaxStatementCacheSize)
- {
- opoConCtx.pOpoConValCtx->StmtCacheSize = OraTrace.MaxStatementCacheSize;
- }
- }
- num = OpsCon.Open(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, ref opoConCtx.opoConRefCtx);
- if (num == 0 && (OraTrace.m_PerformanceCounters & PerfCounterLevel.HardConnectsPerSecond) == PerfCounterLevel.HardConnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardConnectsPerSecond, opoConCtx);
- }
- if (opoConCtx.metaPool == 1)
- {
- if (opoConCtx.m_bSelfTuning)
- {
- int maxElemsInPool = (opoConCtx.pOpoConValCtx->StmtCacheSize > ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON) ? opoConCtx.pOpoConValCtx->StmtCacheSize : ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON;
- opoConCtx.m_conPooler = new ConPooler(maxElemsInPool);
- opoConCtx.m_udtDescPoolerByName = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON);
- }
- else
- {
- opoConCtx.m_conPooler = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
- opoConCtx.m_udtDescPoolerByName = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
- }
- }
- if (opoConCtx.m_bSelfTuning)
- {
- opoConCtx.m_udtDescPoolerByTDO = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_ON);
- }
- else
- {
- opoConCtx.m_udtDescPoolerByTDO = new ConPooler(ConPooler.DEFAULT_MAX_ELEMS_IN_POOL_TUNING_OFF);
- }
- if (num == 0 && this.m_clonedCtx.opoConRefCtx.dbName == null)
- {
- this.m_clonedCtx.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
- this.m_clonedCtx.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
- this.m_clonedCtx.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
- this.m_clonedCtx.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
- }
- if (num == 0 && (num = ConnectionDispenser.RegisterCallbacks(opoConCtx)) != 0)
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- OpoConValCtx* ptr = null;
- try
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PopulatePool) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- }
- if (num != 0)
- {
- if (opoConCtx.validateCon == 1)
- {
- goto IL_9F3;
- }
- lock (this.m_bGridRac ? this.m_cpCtx.m_counter : this.m_counter)
- {
- 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))
- {
- goto IL_9F3;
- }
- }
- }
- opoConCtx.creationTime = DateTime.Now;
- this.m_skipDecrement = true;
- if (this.m_cpCtx != null)
- {
- this.m_cpCtx.m_cpCtxSkipDecrement = true;
- }
- bool flag4 = false;
- if (opoConCtx.pOpoConValCtx->SessionBegin == 1)
- {
- flag4 = true;
- }
- int num6;
- if (this.m_bGridRac)
- {
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- lock (this.m_cpCtx.htInstToCp.SyncRoot)
- {
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
- this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) New CP created (CP id: ",
- connectionPool.GetHashCode(),
- "; CPCtx id: ",
- this.m_cpCtx.GetHashCode(),
- ") for: [Instance=",
- opoConCtx.opoConRefCtx.instanceName,
- "]\n"
- })
- });
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) Num of Inst CPs in (CPCtx id: ",
- this.m_cpCtx.GetHashCode(),
- ") : ",
- this.m_cpCtx.htInstToCp.Count,
- "\n"
- })
- });
- }
- }
- }
- }
- if (this.m_clonedCtx.gridCR == 1)
- {
- if (opoConCtx.pooledConCtx == null)
- {
- opoConCtx.pooledConCtx = PooledConCtx.CopyOpoConCtx(opoConCtx);
- }
- if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx) && opoConCtx.opsConCtx != IntPtr.Zero)
- {
- connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PopulatePool) Pool Id = ",
- connectionPool.m_poolId,
- " Added PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- }
- num5++;
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections)
- {
- num6 = connectionPool.PutConnection(ref opoConCtx, true, false, true, 0, true, true);
- goto IL_980;
- }
- }
- num6 = connectionPool.PutConnection(ref opoConCtx, true, false, true, 0, true, true);
- }
- else
- {
- connectionPool = this;
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections)
- {
- num6 = this.PutConnection(ref opoConCtx, true, false, false, 0, true, true);
- goto IL_980;
- }
- }
- num6 = this.PutConnection(ref opoConCtx, true, false, false, 0, true, true);
- }
- IL_980:
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.SoftDisconnectsPerSecond) == PerfCounterLevel.SoftDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.SoftDisconnectsPerSecond, opoConCtx);
- }
- if (flag4 && num == 0 && num6 == 0)
- {
- connectionPool.UpdateTotalCount(1, false);
- if (connectionPool == this)
- {
- num3++;
- }
- else
- {
- connectionPool.m_counter.UpdatePotentialTotalCount(1);
- }
- num4++;
- }
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- }
- finally
- {
- opoConCtx.opoConRefCtx.password = null;
- opoConCtx.opoConRefCtx.proxyPassword = null;
- }
- IL_9F3:;
- }
- }
- }
- if (this.m_bGridRac && num5 - num4 > 0)
- {
- this.m_cpCtx.m_counter.UpdatePotentialTotalCount(num4 - num5);
- }
- if (num5 - num3 > 0)
- {
- this.m_counter.UpdatePotentialTotalCount(num3 - num5);
- }
- }
- finally
- {
- if (windowsImpersonationContext != null)
- {
- try
- {
- windowsImpersonationContext.Undo();
- }
- catch (Exception ex4)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) (ERROR) ConnectionPool::PopulatePool(): Pool (id: ",
- this.m_clonedCtx.conString.GetHashCode(),
- "); Exception: ",
- ex4.ToString(),
- " \n"
- })
- });
- }
- }
- windowsImpersonationContext = null;
- }
- }
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- " (POOL) (EXIT) ConnectionPool::PopulatePool(): Pool (id: " + this.m_clonedCtx.conString.GetHashCode() + ");\n"
- });
- }
- }
- public static void PerformanceCounterIncrement(OraclePerfParams.CounterIndex iCounter, OpoConCtx opoConCtx)
- {
- if (opoConCtx.pool == null || (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null))
- {
- OraclePerfCounter oraclePerfCounter = OraclePerfCounterCollection.Increment(iCounter, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
- if (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null)
- {
- opoConCtx.pool.m_perfCounterRefs[(int)iCounter] = oraclePerfCounter;
- return;
- }
- }
- else
- {
- opoConCtx.pool.m_perfCounterRefs[(int)iCounter].Increment();
- }
- }
- public static void PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex iCounter, int value, OpoConCtx opoConCtx)
- {
- if (opoConCtx.pool == null || (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null))
- {
- OraclePerfCounter oraclePerfCounter = OraclePerfCounterCollection.IncrementBy(iCounter, value, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
- if (opoConCtx.pool != null && opoConCtx.pool.m_perfCounterRefs[(int)iCounter] == null)
- {
- opoConCtx.pool.m_perfCounterRefs[(int)iCounter] = oraclePerfCounter;
- return;
- }
- }
- else
- {
- opoConCtx.pool.m_perfCounterRefs[(int)iCounter].IncrementBy(value);
- }
- }
- public static void PerformanceCounterDecrement(OraclePerfParams.CounterIndex iCounter, OpoConCtx opoConCtx)
- {
- if (opoConCtx.pool == null)
- {
- OraclePerfCounterCollection.Decrement(iCounter, opoConCtx.poolName, ConnectionPool.GetInstanceName(opoConCtx));
- return;
- }
- opoConCtx.pool.m_perfCounterRefs[(int)iCounter].Decrement();
- }
- internal static string GetInstanceName(OpoConCtx opoConCtx)
- {
- string result = null;
- if (opoConCtx.gridCR == 1 || opoConCtx.gridRLB == 1)
- {
- result = opoConCtx.opoConRefCtx.instanceName;
- }
- return result;
- }
- public void UpdateTotalCount(int val, bool bForPotential)
- {
- if (this.m_clonedCtx.bGridRac)
- {
- this.m_cpCtx.m_counter.UpdateTotalCount(this, val, bForPotential);
- }
- this.m_counter.UpdateTotalCount(this, val, bForPotential);
- }
- public void UpdatePotentialTotalCount(int val)
- {
- if (this.m_clonedCtx.bGridRac)
- {
- this.m_cpCtx.m_counter.UpdatePotentialTotalCount(val);
- }
- this.m_counter.UpdatePotentialTotalCount(val);
- }
- public void UpdateThreadWaitCount(int val)
- {
- this.m_counter.UpdateThreadWaitCount(this, val);
- }
- public void RegulateNumOfConsThreadFunc(object state)
- {
- this.RegulateNumOfCons(state);
- }
- public void GetDisposalInfo(int totDecrCount, ref ConnectionPool[] conPool, ref int[] consToClose)
- {
- conPool = null;
- consToClose = null;
- int[] array = null;
- int num = 0;
- int num2 = 2147483647;
- int num3 = 0;
- if (this.m_cpCtx != null && this.m_cpCtx.htInstToCp != null)
- {
- num3 = this.m_cpCtx.htInstToCp.Count;
- }
- if (this.m_cpCtx != null && this.m_cpCtx.htInstToCp != null && num3 > 0)
- {
- int num4 = this.m_cpCtx.m_random.Next(0, num3);
- lock (this.m_cpCtx.htInstToCp)
- {
- num3 = this.m_cpCtx.htInstToCp.Count;
- if (num3 > 0)
- {
- IDictionaryEnumerator enumerator = this.m_cpCtx.htInstToCp.GetEnumerator();
- conPool = new ConnectionPool[num3];
- array = new int[num3];
- while (enumerator.MoveNext())
- {
- conPool[num4] = (ConnectionPool)enumerator.Value;
- array[num4] = conPool[num4].m_connections.Count;
- num += array[num4];
- if (array[num4] < num2)
- {
- num2 = array[num4];
- }
- num4 = (num4 + 1) % num3;
- }
- }
- }
- if (num <= totDecrCount)
- {
- consToClose = array;
- return;
- }
- int num5 = 0;
- consToClose = new int[num3];
- if (num2 * num3 > totDecrCount)
- {
- num2 = totDecrCount / num3;
- for (int i = 0; i < num3; i++)
- {
- consToClose[i] = num2;
- array[i] -= num2;
- num5 += num2;
- }
- }
- for (int i = 0; i < num3 * totDecrCount; i++)
- {
- num4 = i % num3;
- if (array[num4] > 0)
- {
- consToClose[num4]++;
- array[num4]--;
- num5++;
- if (num5 >= totDecrCount)
- {
- return;
- }
- }
- }
- }
- }
- public unsafe int RegulateNumOfCons(object state)
- {
- bool flag = false;
- int num = 0;
- bool flag2 = state == null;
- bool bGridRac = this.m_clonedCtx.bGridRac;
- try
- {
- if (this.m_cpCtx != null)
- {
- Monitor.Enter(this.m_cpCtx);
- }
- int num2;
- int total;
- int potentialTotal;
- int num3;
- bool flag3;
- if (bGridRac)
- {
- num2 = this.m_cpCtx.totalAvaliableConnections;
- total = this.m_cpCtx.m_counter.total;
- potentialTotal = this.m_cpCtx.m_counter.potentialTotal;
- num3 = this.m_clonedCtx.origMinPoolSize;
- flag3 = this.m_cpCtx.m_cpCtxSkipDecrement;
- }
- else
- {
- num2 = this.m_connections.Count;
- total = this.m_counter.total;
- potentialTotal = this.m_counter.potentialTotal;
- num3 = this.m_clonedCtx.minPoolSize;
- flag3 = this.m_skipDecrement;
- }
- if (num2 > 0 && (total > num3 || this.m_rlbGravCounter > 0 || (state != null && (int)state == -1)) && (!flag3 || state != null))
- {
- int num4 = 0;
- if (state == null)
- {
- if (num2 < this.m_clonedCtx.poolDecSize)
- {
- num4 = num2;
- }
- else
- {
- num4 = this.m_clonedCtx.poolDecSize;
- }
- if (total - num4 < num3)
- {
- num4 = total - num3;
- }
- }
- else
- {
- bool flag4 = false;
- try
- {
- Monitor.Enter(this, ref flag4);
- if ((int)state == -1)
- {
- num4 = this.m_clonedCtx.maxPoolSize;
- }
- else
- {
- if (this.m_rlbGravCounter <= 0)
- {
- num4 = Math.Min((int)state, total - num3);
- }
- else
- {
- if (this.m_rlbGravCounter > 0)
- {
- num4 = this.m_rlbGravCounter;
- this.m_rlbGravCounter = 0;
- }
- }
- }
- }
- finally
- {
- if (flag4)
- {
- Monitor.Exit(this);
- }
- }
- }
- bool flag5 = this.m_cpCtx != null && this.m_cpCtx.m_rlbCtx.RLBMetricsList != null && this.m_cpCtx.m_rlbCtx.RLBMetricsList.Count != 0;
- if (bGridRac && flag2 && !flag5)
- {
- ConnectionPool[] array = null;
- int[] array2 = null;
- this.GetDisposalInfo(num4, ref array, ref array2);
- if (array != null)
- {
- for (int i = 0; i < array.Length; i++)
- {
- array[i].RegulateNumOfCons(array2[i]);
- array[i] = null;
- }
- }
- }
- else
- {
- if (!bGridRac || !flag2 || !flag5)
- {
- for (int j = 0; j < num4; j++)
- {
- PooledConCtx pooledConCtx = null;
- try
- {
- int num5 = 0;
- if (bGridRac && this.m_cpCtx != null)
- {
- num5 = OpsCon.WaitForSingleObject(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 0);
- }
- int num6 = 0;
- if (num5 == 0)
- {
- num6 = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, 0);
- }
- if (num6 == 0 && num5 == 0)
- {
- if (bGridRac && this.m_cpCtx != null)
- {
- Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
- }
- Interlocked.Decrement(ref this.m_counter.totalAvailable);
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections.SyncRoot)
- {
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- goto IL_304;
- }
- }
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- IL_304:
- if (pooledConCtx != null)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
- }
- }
- if (pooledConCtx.pOpoConValCtx->bTAFEnabled == 1)
- {
- ConnectionPool connectionPool = this;
- string instanceName = pooledConCtx.opoConRefCtx.instanceName;
- OpsCon.GetAttributes(pooledConCtx.opsConCtx, pooledConCtx.opsErrCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- if (instanceName != pooledConCtx.opoConRefCtx.instanceName)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new string[]
- {
- " (FO) Failed over from ",
- instanceName,
- " to ",
- pooledConCtx.opoConRefCtx.instanceName,
- "\n"
- })
- });
- connectionPool.m_conList.Remove(pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (RegulateNumOfCons) Pool Id = ",
- connectionPool.m_poolId,
- " Removed(1) PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- flag = true;
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[pooledConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- lock (this.m_cpCtx.htInstToCp.SyncRoot)
- {
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[pooledConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- OpoConCtx opoConCtx = new OpoConCtx();
- opoConCtx.pooledConCtx = pooledConCtx;
- opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
- opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
- opoConCtx.pOpoConValCtx = pooledConCtx.pOpoConValCtx;
- opoConCtx.opoConRefCtx = pooledConCtx.opoConRefCtx;
- connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
- this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) New CP created (CP id: ",
- connectionPool.GetHashCode(),
- "; CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") for: [Instance=",
- opoConCtx.opoConRefCtx.instanceName,
- "]\n"
- })
- });
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) Num of Inst CPs in (CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") : ",
- connectionPool.m_cpCtx.htInstToCp.Count,
- "\n"
- })
- });
- }
- }
- }
- }
- if (this.m_bSynchronizeStack)
- {
- lock (connectionPool.m_connections.SyncRoot)
- {
- connectionPool.m_connections.Push(pooledConCtx);
- if (connectionPool.m_clonedCtx.gridCR == 1)
- {
- if (!connectionPool.m_conList.Contains(pooledConCtx))
- {
- connectionPool.m_conList.Add(pooledConCtx);
- }
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (RegulateNumOfCons) Pool Id = ",
- connectionPool.m_poolId,
- " Added(1) PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- goto IL_7D9;
- }
- }
- connectionPool.m_connections.Push(pooledConCtx);
- if (connectionPool.m_clonedCtx.gridCR == 1)
- {
- if (!connectionPool.m_conList.Contains(pooledConCtx))
- {
- connectionPool.m_conList.Add(pooledConCtx);
- }
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (RegulateNumOfCons) Pool Id = ",
- connectionPool.m_poolId,
- " Added(2) PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- IL_7D9:
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
- }
- if (bGridRac && connectionPool.m_cpCtx != null)
- {
- Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
- }
- Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
- connectionPool.ReleaseSemaphore();
- Interlocked.Decrement(ref this.m_counter.total);
- Interlocked.Increment(ref connectionPool.m_counter.total);
- }
- else
- {
- num++;
- this.UpdateTotalCount(-1, true);
- }
- }
- else
- {
- num++;
- this.UpdateTotalCount(-1, true);
- }
- }
- else
- {
- if (bGridRac && this.m_cpCtx != null && num5 == 0)
- {
- int num7 = 0;
- OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num7);
- }
- else
- {
- if (num6 == 0)
- {
- int num8 = 0;
- OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num8);
- }
- }
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- if (pooledConCtx == null)
- {
- break;
- }
- if (!flag)
- {
- try
- {
- if (pooledConCtx.m_fetchArrayPooler != null)
- {
- pooledConCtx.m_fetchArrayPooler.Dispose();
- pooledConCtx.m_fetchArrayPooler = null;
- }
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- lock (pooledConCtx.m_syncObject)
- {
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- if (this.m_clonedCtx.gridCR == 1)
- {
- this.m_conList.Remove(pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (RegulateNumOfCons) Pool Id = ",
- this.m_poolId,
- " Removed(2) PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- finally
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
- }
- pooledConCtx.opsConCtx = IntPtr.Zero;
- pooledConCtx.opsErrCtx = IntPtr.Zero;
- pooledConCtx.pOpoConValCtx = null;
- pooledConCtx.m_conPooler = null;
- pooledConCtx.m_udtDescPoolerByName = null;
- pooledConCtx.m_udtDescPoolerByTDO = null;
- }
- }
- }
- }
- }
- }
- else
- {
- if (total == 0 && num2 == 0 && num3 == 0 && potentialTotal == 0 && flag2)
- {
- if (bGridRac)
- {
- lock (this.m_cpCtx.m_rlbCtx.htConToInst.SyncRoot)
- {
- 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)
- {
- this.m_cpCtx.m_rlbCtx.htConToInst.Remove(this.m_clonedCtx.conString);
- }
- if (this.m_clonedCtx.metaPool == 1)
- {
- DeriveParamInfo.m_pooler.RemovePool(this.m_clonedCtx.conString);
- }
- this.m_cpCtx.m_timer.Dispose();
- goto IL_C7B;
- }
- }
- lock (ConnectionDispenser.s_lockObj)
- {
- if (this.m_counter.total == 0 && this.m_connections.Count == 0 && this.m_clonedCtx.minPoolSize == 0 && this.m_counter.potentialTotal == 0)
- {
- ConnectionPool connectionPool2 = (ConnectionPool)ConnectionDispenser.m_ConnectionPools[this.m_clonedCtx.conString];
- ConnectionDispenser.m_ConnectionPools.Remove(this.m_clonedCtx.conString);
- connectionPool2.Dispose();
- if (this.m_clonedCtx.metaPool == 1)
- {
- DeriveParamInfo.m_pooler.RemovePool(this.m_clonedCtx.conString);
- }
- this.m_timer.Dispose();
- }
- goto IL_C7B;
- }
- }
- if (potentialTotal < num3)
- {
- int num9;
- if (potentialTotal + this.m_clonedCtx.poolIncSize > this.m_clonedCtx.maxPoolSize)
- {
- num9 = this.m_clonedCtx.maxPoolSize - potentialTotal;
- }
- else
- {
- num9 = this.m_clonedCtx.poolIncSize;
- }
- if (num9 > 0)
- {
- ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), num9);
- this.UpdatePotentialTotalCount(num9);
- }
- }
- }
- IL_C7B:;
- }
- catch
- {
- }
- finally
- {
- if (this.m_cpCtx != null)
- {
- Monitor.Exit(this.m_cpCtx);
- }
- }
- if (state == null)
- {
- this.m_skipDecrement = false;
- }
- if (this.m_cpCtx != null)
- {
- this.m_cpCtx.m_cpCtxSkipDecrement = false;
- }
- if ((bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0)
- {
- if (!this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- this.m_inactive = true;
- }
- }
- else
- {
- if (this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- this.m_inactive = false;
- }
- }
- return num;
- }
- public unsafe int CheckLifeTimeAndStatus(ref OpoConCtx opoConCtx, bool bDistTxnActive, ref bool bClosed, int bFromPool, bool bCheckLifetimeOnly, bool bFreeValCtxOnDispose)
- {
- int result = 0;
- bool bGridRac = opoConCtx.bGridRac;
- bool flag = false;
- OpoConValCtx* ptr = null;
- if ((!bGridRac || bFromPool != 1) && !bDistTxnActive)
- {
- int total;
- if (this.m_cpCtx != null)
- {
- total = this.m_cpCtx.m_counter.total;
- }
- else
- {
- total = this.m_counter.total;
- }
- bool flag2 = false;
- try
- {
- Monitor.Enter(this, ref flag2);
- if (this.m_rlbGravCounter > 0)
- {
- this.m_rlbGravCounter--;
- flag = true;
- }
- }
- finally
- {
- if (flag2)
- {
- Monitor.Exit(this);
- }
- }
- 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))))
- {
- if (!flag)
- {
- goto IL_312;
- }
- }
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (CheckLifeTimeAndStatus) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(1) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- if (bFreeValCtxOnDispose)
- {
- ptr = opoConCtx.pOpoConValCtx;
- opoConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- bClosed = true;
- if (flag)
- {
- this.UpdatePotentialTotalCount(1);
- ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), 1);
- }
- return 0;
- }
- IL_312:
- if (bCheckLifetimeOnly)
- {
- bClosed = false;
- return 0;
- }
- try
- {
- if (bFromPool == 0 && !bDistTxnActive && ((opoConCtx.opoConRefCtx.proxyUserId != null && opoConCtx.opoConRefCtx.proxyUserId.Length > 0) || opoConCtx.pOpoConValCtx->OSAuthent == 2))
- {
- OpsCon.CloseProxyAuthUserSession(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- }
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- int num = 1;
- bool flag4 = false;
- try
- {
- if (bFromPool == 0 || opoConCtx.validateCon == 1)
- {
- num = 0;
- OpsCon.CheckConStatus(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opsErrCtx, bDistTxnActive ? 1 : 0, ref num, bFromPool, opoConCtx.validateCon);
- }
- }
- catch (Exception ex3)
- {
- flag4 = true;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- }
- if (num == 0)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- if (flag4)
- {
- OraTrace.Trace(1u, new string[]
- {
- " (VALID) Exception in OpsCon.CheckConStatus\n"
- });
- }
- else
- {
- OraTrace.Trace(1u, new string[]
- {
- " (VALID) Dead connection\n"
- });
- }
- }
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (CheckLifeTimeAndStatus) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(2) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- if (bFromPool == 0 && bFreeValCtxOnDispose)
- {
- ptr = opoConCtx.pOpoConValCtx;
- opoConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex4)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex4);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- bClosed = true;
- }
- else
- {
- bClosed = false;
- }
- return result;
- }
- private unsafe void GetEnlistedConnection(ref PooledConCtx pooledConCtx, OpoConCtx opoConCtx)
- {
- try
- {
- if (string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) && opoConCtx.pOpoConValCtx->OSAuthent != 2)
- {
- pooledConCtx = (PooledConCtx)this.m_oraResPool.GetResource(opoConCtx.m_systemTransaction.TransactionInformation.LocalIdentifier);
- }
- else
- {
- string userID = opoConCtx.opoConRefCtx.userID;
- string password = opoConCtx.opoConRefCtx.password;
- pooledConCtx = opoConCtx.pool.m_oraResPool.GetResourceMatchingEndUser(Transaction.Current.TransactionInformation.LocalIdentifier, userID, password);
- }
- if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- }
- catch
- {
- }
- }
- private void GetRegularConnection(ref PooledConCtx pooledConCtx)
- {
- try
- {
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections.SyncRoot)
- {
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- goto IL_4E;
- }
- }
- pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- IL_4E:
- if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
- }
- }
- catch
- {
- }
- }
- public unsafe int CopyPooledToCon(ref OpoConCtx opoConCtx, ref PooledConCtx pooledConCtx, bool bOpenEndUserSession)
- {
- int num = 0;
- int num2 = 0;
- int sessionBegin = 1;
- opoConCtx.pooledConCtx = pooledConCtx;
- if (opoConCtx.opsConCtx != IntPtr.Zero && opoConCtx.opsErrCtx != IntPtr.Zero)
- {
- OpoConValCtx* ptr = null;
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (CopyPooledToCon) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- }
- opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
- opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
- opoConCtx.creationTime = pooledConCtx.creationTime;
- opoConCtx.m_syncObject = pooledConCtx.m_syncObject;
- num = ConnectionDispenser.CopyPooledConCtx(ref opoConCtx.pOpoConValCtx, pooledConCtx.pOpoConValCtx);
- try
- {
- if (num == 0 && bOpenEndUserSession && opoConCtx.pOpoConValCtx->SessionBegin == 1)
- {
- if (opoConCtx.opoConRefCtx.proxyUserId == null || opoConCtx.opoConRefCtx.proxyUserId.Length <= 0)
- {
- if (opoConCtx.pOpoConValCtx->OSAuthent != 2)
- {
- goto IL_28F;
- }
- }
- try
- {
- num2 = OpsCon.OpenProxyAuthUserSession(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- num = ErrRes.INT_ERR;
- opoConCtx.exceptMsg = ex2.ToString();
- }
- }
- IL_28F:;
- }
- finally
- {
- if (num2 != 0)
- {
- sessionBegin = opoConCtx.pOpoConValCtx->SessionBegin;
- opoConCtx.pOpoConValCtx->SessionBegin = 1;
- num = num2;
- }
- if (num != 0)
- {
- if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.m_systemTransaction != null)
- {
- this.PushToResourcePool(opoConCtx, pooledConCtx);
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- }
- else
- {
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections)
- {
- this.PutConnection(ref opoConCtx, false, true, true, 0, false, true);
- goto IL_342;
- }
- }
- this.PutConnection(ref opoConCtx, false, true, true, 0, false, true);
- }
- IL_342:
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- }
- }
- opoConCtx.opoConRefCtx.serverVersion = pooledConCtx.opoConRefCtx.serverVersion;
- opoConCtx.opoConRefCtx.dataSource = pooledConCtx.opoConRefCtx.dataSource;
- opoConCtx.opoConRefCtx.dbName = pooledConCtx.opoConRefCtx.dbName;
- opoConCtx.opoConRefCtx.hostName = pooledConCtx.opoConRefCtx.hostName;
- opoConCtx.opoConRefCtx.serviceName = pooledConCtx.opoConRefCtx.serviceName;
- opoConCtx.opoConRefCtx.instanceName = pooledConCtx.opoConRefCtx.instanceName;
- opoConCtx.opoConRefCtx.dbDomainName = pooledConCtx.opoConRefCtx.dbDomainName;
- opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg = pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
- opoConCtx.m_conPooler = pooledConCtx.m_conPooler;
- opoConCtx.m_udtDescPoolerByName = pooledConCtx.m_udtDescPoolerByName;
- opoConCtx.m_udtDescPoolerByTDO = pooledConCtx.m_udtDescPoolerByTDO;
- opoConCtx.m_txnid = pooledConCtx.m_txnid;
- opoConCtx.m_promotableTxnManager = pooledConCtx.m_promotableTxnManager;
- opoConCtx.m_fetchArrayPooler = pooledConCtx.m_fetchArrayPooler;
- opoConCtx.m_statementData = pooledConCtx.m_statementData;
- opoConCtx.m_totalDataAvailable = pooledConCtx.m_totalDataAvailable;
- if (num2 != 0)
- {
- opoConCtx.pOpoConValCtx->SessionBegin = sessionBegin;
- }
- return num;
- }
- private void CreateMoreConnections()
- {
- int potentialTotal;
- if (this.m_cpCtx != null)
- {
- potentialTotal = this.m_cpCtx.m_counter.potentialTotal;
- }
- else
- {
- potentialTotal = this.m_counter.potentialTotal;
- }
- int num;
- if (potentialTotal + this.m_clonedCtx.poolIncSize > this.m_clonedCtx.maxPoolSize)
- {
- num = this.m_clonedCtx.maxPoolSize - potentialTotal;
- }
- else
- {
- num = this.m_clonedCtx.poolIncSize;
- }
- if (num > 0)
- {
- ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulatePool), num);
- this.UpdatePotentialTotalCount(num);
- }
- }
- private int WaitForRegularConnection(ref OpoConCtx opoConCtx, ref PooledConCtx pooledConCtx)
- {
- int num = 0;
- int num2 = 0;
- this.UpdateThreadWaitCount(1);
- double num3;
- if (this.m_bGridRac)
- {
- num3 = 0.0;
- }
- else
- {
- num3 = opoConCtx.timeOut.TotalSeconds;
- }
- try
- {
- num = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, (int)num3 * 1000);
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- num = ErrRes.INT_ERR;
- opoConCtx.exceptMsg = ex.ToString();
- }
- finally
- {
- this.UpdateThreadWaitCount(-1);
- }
- if (num == ErrRes.INT_ERR)
- {
- return num;
- }
- int num4 = num;
- if (num4 != 0)
- {
- if (num4 == 128 || num4 == 258)
- {
- if (this.m_bGridRac)
- {
- Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
- }
- else
- {
- Interlocked.Increment(ref this.m_counter.totalAvailable);
- }
- if (!(this.m_bGridRac ? (this.m_cpCtx.m_counter.total >= this.m_cpCtx.m_maxPoolSize) : (this.m_counter.total >= this.m_clonedCtx.maxPoolSize)))
- {
- return ErrRes.CON_TIMEOUT_EXCEEDED;
- }
- return ErrRes.CON_POOLED_TIMEOUT_EXCEEDED;
- }
- }
- else
- {
- this.GetRegularConnection(ref pooledConCtx);
- if (pooledConCtx == null)
- {
- 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);
- if (this.m_bGridRac)
- {
- Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
- }
- else
- {
- Interlocked.Increment(ref this.m_counter.totalAvailable);
- }
- try
- {
- OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num2);
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- return num;
- }
- }
- return 0;
- }
- public unsafe int GetConnection(OpoConCtx opoConCtx)
- {
- int num = 0;
- PooledConCtx pooledConCtx = null;
- bool flag = false;
- bool flag2 = false;
- bool flag3 = false;
- DateTime now = DateTime.Now;
- try
- {
- if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.m_systemTransaction != null)
- {
- flag2 = true;
- }
- while (true)
- {
- flag = false;
- pooledConCtx = null;
- int inMtsTxn = 0;
- if (flag2)
- {
- this.GetEnlistedConnection(ref pooledConCtx, opoConCtx);
- if (pooledConCtx != null)
- {
- inMtsTxn = 1;
- flag3 = true;
- if (opoConCtx.bGridRac && this.m_cpCtx != null)
- {
- Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
- Interlocked.Increment(ref this.m_counter.totalAvailable);
- int num2 = 0;
- OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num2);
- }
- }
- }
- if (pooledConCtx == null)
- {
- num = this.WaitForRegularConnection(ref opoConCtx, ref pooledConCtx);
- if (num != 0)
- {
- break;
- }
- }
- if (pooledConCtx != null)
- {
- num = this.CopyPooledToCon(ref opoConCtx, ref pooledConCtx, !flag3);
- if (num != 0)
- {
- goto Block_17;
- }
- }
- if (opoConCtx.pOpoConValCtx->SessionBegin == 1 && opoConCtx.validateCon == 1)
- {
- this.CheckLifeTimeAndStatus(ref opoConCtx, flag3, ref flag, 1, false, false);
- }
- if (!flag)
- {
- goto Block_20;
- }
- if (DateTime.Now - now >= opoConCtx.timeOut)
- {
- goto Block_24;
- }
- }
- if (opoConCtx.bGridRac && this.m_cpCtx != null)
- {
- int num3 = 0;
- OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num3);
- }
- int result = num;
- return result;
- Block_17:
- result = num;
- return result;
- Block_20:
- bool flag4 = true;
- if (!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2)
- {
- flag4 = false;
- }
- if (flag2 && flag4)
- {
- int inMtsTxn;
- opoConCtx.pOpoConValCtx->InMtsTxn = inMtsTxn;
- }
- if (opoConCtx.pOpoConValCtx->Enlist == 1 && opoConCtx.pOpoConValCtx->InMtsTxn == 0 && opoConCtx.pOpoConValCtx->SessionBegin == 1)
- {
- if (opoConCtx.opoConRefCtx.proxyUserId != null)
- {
- if (opoConCtx.opoConRefCtx.proxyUserId.Length != 0)
- {
- goto IL_275;
- }
- }
- try
- {
- num = OpsCon.Enlist(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- num = ErrRes.INT_ERR;
- opoConCtx.exceptMsg = ex.ToString();
- }
- finally
- {
- if (num != 0)
- {
- opoConCtx.pOpoConValCtx->InMtsTxn = 0;
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections)
- {
- this.PutConnection(ref opoConCtx, false, true, true, 0, false, false);
- goto IL_26C;
- }
- }
- this.PutConnection(ref opoConCtx, false, true, true, 0, false, false);
- }
- IL_26C:;
- }
- if (num != 0)
- {
- result = num;
- return result;
- }
- }
- IL_275:
- goto IL_28E;
- Block_24:
- result = ErrRes.CON_TIMEOUT_EXCEEDED;
- return result;
- }
- catch (Exception ex2)
- {
- num = ErrRes.INT_ERR;
- opoConCtx.exceptMsg = ex2.ToString();
- }
- IL_28E:
- if (this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, opoConCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, opoConCtx);
- }
- this.m_inactive = false;
- }
- return num;
- }
- public int ReleaseSemaphore()
- {
- int num = 0;
- int num2 = 0;
- try
- {
- OpsCon.ReleaseSemaphore(this.m_semAvaNumOfCons, 1, ref num);
- if (this.m_cpCtx != null)
- {
- OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num2);
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- return 0;
- }
- public unsafe int PutConnection(ref OpoConCtx opoConCtx, bool bDoNotAllocValCtx, bool bCheckStatus, bool bCheckLifeTime, int bDistTxnActive, bool isPopulatePool, bool bFreeValCtxOnDispose)
- {
- bool flag = false;
- int num = 0;
- bool flag2 = false;
- ConnectionPool connectionPool = this;
- if (opoConCtx.pOpoConValCtx->StmtCacheSize > 0 && opoConCtx.pOpoConValCtx->StmtCachePurge == 1)
- {
- try
- {
- num = OpsCon.PurgeStatementCache(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx);
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- }
- if ((opoConCtx.pOpoConValCtx->InMtsTxn == 1 && opoConCtx.m_systemTransaction != null) || opoConCtx.m_promotableTxnManager != null)
- {
- if (bCheckStatus)
- {
- this.CheckLifeTimeAndStatus(ref opoConCtx, true, ref flag, 0, false, bFreeValCtxOnDispose);
- if (flag)
- {
- if (opoConCtx.m_promotableTxnManager != null)
- {
- opoConCtx.m_promotableTxnManager.m_bConnectionClosed = true;
- }
- return -1;
- }
- }
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
- opoConCtx.pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
- opoConCtx.pooledConCtx.m_statementData = opoConCtx.m_statementData;
- opoConCtx.pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
- opoConCtx.pooledConCtx.m_txnid = opoConCtx.m_txnid;
- opoConCtx.pooledConCtx.pOpoConValCtx->InMtsTxn = (*opoConCtx.pOpoConValCtx).InMtsTxn;
- opoConCtx.pooledConCtx.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
- if ((!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2) && (opoConCtx.pooledConCtx.m_encryptedPassword == null || opoConCtx.pooledConCtx.m_encryptedPassword.Password != opoConCtx.opoConRefCtx.password))
- {
- opoConCtx.pooledConCtx.m_encryptedPassword = new EncryptedPassword(opoConCtx.opoConRefCtx.password);
- }
- this.PushToResourcePool(opoConCtx, opoConCtx.pooledConCtx);
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- }
- else
- {
- PooledConCtx pooledConCtx = new PooledConCtx();
- pooledConCtx.opsConCtx = opoConCtx.opsConCtx;
- pooledConCtx.opsErrCtx = opoConCtx.opsErrCtx;
- pooledConCtx.conString = opoConCtx.conString;
- pooledConCtx.creationTime = opoConCtx.creationTime;
- pooledConCtx.m_poolName = opoConCtx.poolName;
- pooledConCtx.m_syncObject = opoConCtx.m_syncObject;
- if (bDoNotAllocValCtx)
- {
- pooledConCtx.pOpoConValCtx = opoConCtx.pOpoConValCtx;
- opoConCtx.pOpoConValCtx = null;
- }
- else
- {
- num = ConnectionDispenser.CopyPooledConCtx(ref pooledConCtx.pOpoConValCtx, opoConCtx.pOpoConValCtx);
- if (num != 0)
- {
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(0) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- opoConCtx.m_promotableTxnManager = null;
- this.UpdateTotalCount(-1, true);
- return -1;
- }
- }
- pooledConCtx.opoConRefCtx = new OpoConRefCtx();
- pooledConCtx.opoConRefCtx.serverVersion = opoConCtx.opoConRefCtx.serverVersion;
- pooledConCtx.opoConRefCtx.dataSource = opoConCtx.opoConRefCtx.dataSource;
- pooledConCtx.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
- pooledConCtx.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
- pooledConCtx.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
- pooledConCtx.opoConRefCtx.instanceName = opoConCtx.opoConRefCtx.instanceName;
- pooledConCtx.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
- pooledConCtx.opoConRefCtx.proxyUserId = opoConCtx.opoConRefCtx.proxyUserId;
- pooledConCtx.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
- pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg = opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
- pooledConCtx.m_conPooler = opoConCtx.m_conPooler;
- pooledConCtx.m_udtDescPoolerByName = opoConCtx.m_udtDescPoolerByName;
- pooledConCtx.m_udtDescPoolerByTDO = opoConCtx.m_udtDescPoolerByTDO;
- pooledConCtx.m_txnid = opoConCtx.m_txnid;
- pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
- pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
- pooledConCtx.m_statementData = opoConCtx.m_statementData;
- pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
- if (!string.IsNullOrEmpty(opoConCtx.opoConRefCtx.proxyUserId) || opoConCtx.pOpoConValCtx->OSAuthent == 2)
- {
- pooledConCtx.m_encryptedPassword = new EncryptedPassword(opoConCtx.opoConRefCtx.password);
- }
- this.PushToResourcePool(opoConCtx, pooledConCtx);
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- }
- opoConCtx.pOpoConValCtx->InMtsTxn = 0;
- return num;
- }
- if (opoConCtx.pOpoConValCtx->InMtsTxn == 1 && opoConCtx.m_systemTransaction == null)
- {
- opoConCtx.opoConRefCtx.pITransaction = null;
- try
- {
- num = OpsCon.Enlist(opoConCtx.opsConCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- num = ErrRes.INT_ERR;
- }
- finally
- {
- opoConCtx.pOpoConValCtx->InMtsTxn = 0;
- if (num != 0)
- {
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(1) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex4)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex4);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- }
- }
- if (num != 0)
- {
- return -1;
- }
- }
- if (bCheckStatus || bCheckLifeTime)
- {
- bool bCheckLifetimeOnly = bCheckLifeTime && !bCheckStatus;
- this.CheckLifeTimeAndStatus(ref opoConCtx, false, ref flag, 0, bCheckLifetimeOnly, bFreeValCtxOnDispose);
- if (flag)
- {
- return -1;
- }
- }
- if (this.m_bClearPoolInProgress && opoConCtx.creationTime < this.m_clearRequestTimeStamp)
- {
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(2) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex5)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex5);
- }
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- if (this.m_bGridRac)
- {
- Interlocked.Decrement(ref this.m_cpCtx.m_consFromAppToClear);
- if (this.m_cpCtx.m_consFromAppToClear == 0)
- {
- this.m_bClearPoolInProgress = false;
- }
- }
- else
- {
- Interlocked.Decrement(ref this.m_consFromAppToClear);
- if (this.m_consFromAppToClear == 0)
- {
- this.m_bClearPoolInProgress = false;
- }
- }
- }
- else
- {
- if (opoConCtx.pooledConCtx != null)
- {
- if (bDoNotAllocValCtx)
- {
- opoConCtx.pooledConCtx.pOpoConValCtx = opoConCtx.pOpoConValCtx;
- opoConCtx.pOpoConValCtx = null;
- }
- else
- {
- num = ConnectionDispenser.CopyPooledConCtx(ref opoConCtx.pooledConCtx.pOpoConValCtx, opoConCtx.pOpoConValCtx);
- if (num != 0)
- {
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(3) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex6)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex6);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- return -1;
- }
- }
- if (opoConCtx.pooledConCtx.pOpoConValCtx->bTAFEnabled == 1)
- {
- string instanceName = opoConCtx.opoConRefCtx.instanceName;
- OpsCon.GetAttributes(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, opoConCtx.pooledConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- if (instanceName != opoConCtx.opoConRefCtx.instanceName)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new string[]
- {
- " (FO) Failed over from ",
- instanceName,
- " to ",
- opoConCtx.opoConRefCtx.instanceName,
- "\n"
- })
- });
- flag2 = true;
- if (this.m_clonedCtx.gridCR == 1)
- {
- ConnectionPool connectionPool2 = null;
- try
- {
- connectionPool2 = (ConnectionPool)this.m_cpCtx.htInstToCp[instanceName];
- }
- catch
- {
- }
- if (connectionPool2 != null)
- {
- connectionPool2.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(6) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- }
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- lock (this.m_cpCtx.htInstToCp.SyncRoot)
- {
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
- this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) New CP created (CP id: ",
- connectionPool.GetHashCode(),
- "; CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") for: [Instance=",
- opoConCtx.opoConRefCtx.instanceName,
- "]\n"
- })
- });
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) Num of Inst CPs in (CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") : ",
- connectionPool.m_cpCtx.htInstToCp.Count,
- "\n"
- })
- });
- }
- }
- }
- }
- if (connectionPool.m_clonedCtx.gridCR == 1)
- {
- if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx))
- {
- connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
- }
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- connectionPool.m_poolId,
- " Added(1) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- }
- }
- opoConCtx.pooledConCtx.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
- opoConCtx.pooledConCtx.m_conPooler = opoConCtx.m_conPooler;
- opoConCtx.pooledConCtx.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
- opoConCtx.pooledConCtx.m_statementData = opoConCtx.m_statementData;
- opoConCtx.pooledConCtx.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
- if (this.m_bSynchronizeStack)
- {
- lock (connectionPool.m_connections.SyncRoot)
- {
- connectionPool.m_connections.Push(opoConCtx.pooledConCtx);
- goto IL_11EA;
- }
- }
- connectionPool.m_connections.Push(opoConCtx.pooledConCtx);
- IL_11EA:
- opoConCtx.pool = connectionPool;
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections && isPopulatePool)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, opoConCtx);
- }
- if (this.m_bGridRac && connectionPool.m_cpCtx != null)
- {
- Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
- }
- Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
- connectionPool.ReleaseSemaphore();
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- if (!flag2)
- {
- goto IL_1D54;
- }
- Interlocked.Decrement(ref this.m_counter.total);
- Interlocked.Increment(ref connectionPool.m_counter.total);
- try
- {
- if (this.m_encryptedPasswords.m_encryptedPwd != null)
- {
- opoConCtx.opoConRefCtx.password = this.m_encryptedPasswords.m_encryptedPwd.Password;
- }
- else
- {
- opoConCtx.opoConRefCtx.password = "";
- }
- if (this.m_encryptedPasswords.m_encryptedPxyPwd != null)
- {
- opoConCtx.opoConRefCtx.proxyPassword = this.m_encryptedPasswords.m_encryptedPxyPwd.Password;
- }
- else
- {
- opoConCtx.opoConRefCtx.proxyPassword = "";
- }
- if ((num = ConnectionDispenser.RegisterCallbacks(opoConCtx)) != 0)
- {
- OpoConValCtx* ptr = null;
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(4) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Close(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref ptr, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex7)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex7);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- return num;
- }
- goto IL_1D54;
- }
- finally
- {
- opoConCtx.opoConRefCtx.password = null;
- opoConCtx.opoConRefCtx.proxyPassword = null;
- }
- }
- PooledConCtx pooledConCtx2 = new PooledConCtx();
- pooledConCtx2.opsConCtx = opoConCtx.opsConCtx;
- pooledConCtx2.opsErrCtx = opoConCtx.opsErrCtx;
- pooledConCtx2.conString = opoConCtx.conString;
- pooledConCtx2.creationTime = opoConCtx.creationTime;
- pooledConCtx2.m_poolName = opoConCtx.poolName;
- pooledConCtx2.m_syncObject = opoConCtx.m_syncObject;
- if (bDoNotAllocValCtx)
- {
- pooledConCtx2.pOpoConValCtx = opoConCtx.pOpoConValCtx;
- opoConCtx.pOpoConValCtx = null;
- }
- else
- {
- num = ConnectionDispenser.CopyPooledConCtx(ref pooledConCtx2.pOpoConValCtx, opoConCtx.pOpoConValCtx);
- if (num != 0)
- {
- try
- {
- if (opoConCtx.m_fetchArrayPooler != null)
- {
- opoConCtx.m_fetchArrayPooler.Dispose();
- opoConCtx.m_fetchArrayPooler = null;
- }
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- lock (opoConCtx.m_syncObject)
- {
- if (!opoConCtx.m_bOpsConCtxDisposed)
- {
- if (opoConCtx.pool != null && opoConCtx.pool.m_clonedCtx.gridCR == 1 && opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pool.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(5) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- opoConCtx.pooledConCtx.pOpoConValCtx = null;
- }
- OpsCon.Dispose(ref opoConCtx.opsConCtx, ref opoConCtx.opsErrCtx, ref opoConCtx.pOpoConValCtx, opoConCtx.opoConRefCtx);
- opoConCtx.m_bOpsConCtxDisposed = true;
- if (opoConCtx.pooledConCtx != null)
- {
- opoConCtx.pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- }
- catch (Exception ex8)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex8);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, opoConCtx);
- }
- opoConCtx.pooledConCtx = null;
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- this.UpdateTotalCount(-1, true);
- return -1;
- }
- }
- if (pooledConCtx2.pOpoConValCtx->bTAFEnabled == 1)
- {
- string instanceName2 = opoConCtx.opoConRefCtx.instanceName;
- OpsCon.GetAttributes(opoConCtx.opsConCtx, opoConCtx.opsErrCtx, pooledConCtx2.pOpoConValCtx, opoConCtx.opoConRefCtx);
- if (instanceName2 != opoConCtx.opoConRefCtx.instanceName)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new string[]
- {
- " (FO) Failed over from ",
- instanceName2,
- " to ",
- opoConCtx.opoConRefCtx.instanceName,
- "\n"
- })
- });
- flag2 = true;
- if (this.m_clonedCtx.gridCR == 1)
- {
- ConnectionPool connectionPool3 = null;
- try
- {
- connectionPool3 = (ConnectionPool)this.m_cpCtx.htInstToCp[instanceName2];
- }
- catch
- {
- }
- if (connectionPool3 != null)
- {
- connectionPool3.m_conList.Remove(opoConCtx.pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- opoConCtx.pool.m_poolId,
- " Removed(6) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- }
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- lock (this.m_cpCtx.htInstToCp.SyncRoot)
- {
- connectionPool = (ConnectionPool)this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName];
- if (connectionPool == null)
- {
- connectionPool = new ConnectionPool(opoConCtx, this.m_cpCtx, this.m_identity);
- this.m_cpCtx.htInstToCp[opoConCtx.opoConRefCtx.instanceName] = connectionPool;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) New CP created (CP id: ",
- connectionPool.GetHashCode(),
- "; CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") for: [Instance=",
- opoConCtx.opoConRefCtx.instanceName,
- "]\n"
- })
- });
- OraTrace.Trace(2u, new string[]
- {
- string.Concat(new object[]
- {
- " (POOL) Num of Inst CPs in (CPCtx id: ",
- connectionPool.m_cpCtx.GetHashCode(),
- ") : ",
- connectionPool.m_cpCtx.htInstToCp.Count,
- "\n"
- })
- });
- }
- }
- goto IL_1A7F;
- }
- }
- opoConCtx.pool = connectionPool;
- IL_1A7F:
- if (connectionPool.m_clonedCtx.gridCR == 1)
- {
- if (!connectionPool.m_conList.Contains(opoConCtx.pooledConCtx))
- {
- connectionPool.m_conList.Add(opoConCtx.pooledConCtx);
- }
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (PutConnection) Pool Id = ",
- connectionPool.m_poolId,
- " Added(2) PooledConCtx= ",
- opoConCtx.pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- }
- }
- pooledConCtx2.opoConRefCtx = new OpoConRefCtx();
- pooledConCtx2.opoConRefCtx.serverVersion = opoConCtx.opoConRefCtx.serverVersion;
- pooledConCtx2.opoConRefCtx.dataSource = opoConCtx.opoConRefCtx.dataSource;
- pooledConCtx2.opoConRefCtx.dbName = opoConCtx.opoConRefCtx.dbName;
- pooledConCtx2.opoConRefCtx.hostName = opoConCtx.opoConRefCtx.hostName;
- pooledConCtx2.opoConRefCtx.serviceName = opoConCtx.opoConRefCtx.serviceName;
- pooledConCtx2.opoConRefCtx.instanceName = opoConCtx.opoConRefCtx.instanceName;
- pooledConCtx2.opoConRefCtx.dbDomainName = opoConCtx.opoConRefCtx.dbDomainName;
- pooledConCtx2.opoConRefCtx.proxyUserId = opoConCtx.opoConRefCtx.proxyUserId;
- pooledConCtx2.opoConRefCtx.userID = opoConCtx.opoConRefCtx.userID;
- pooledConCtx2.opoConRefCtx.ttOpsConOpenErrMssg = opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
- pooledConCtx2.m_conPooler = opoConCtx.m_conPooler;
- pooledConCtx2.m_udtDescPoolerByName = opoConCtx.m_udtDescPoolerByName;
- pooledConCtx2.m_udtDescPoolerByTDO = opoConCtx.m_udtDescPoolerByTDO;
- pooledConCtx2.m_txnid = opoConCtx.m_txnid;
- pooledConCtx2.m_promotableTxnManager = opoConCtx.m_promotableTxnManager;
- pooledConCtx2.m_fetchArrayPooler = opoConCtx.m_fetchArrayPooler;
- pooledConCtx2.m_statementData = opoConCtx.m_statementData;
- pooledConCtx2.m_totalDataAvailable = opoConCtx.m_totalDataAvailable;
- if (this.m_bSynchronizeStack)
- {
- lock (connectionPool.m_connections.SyncRoot)
- {
- connectionPool.m_connections.Push(pooledConCtx2);
- goto IL_1CD5;
- }
- }
- connectionPool.m_connections.Push(pooledConCtx2);
- IL_1CD5:
- opoConCtx.pool = connectionPool;
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, opoConCtx);
- }
- if (isPopulatePool && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, opoConCtx);
- }
- bool bGridRac = opoConCtx.bGridRac;
- if (bGridRac && connectionPool.m_cpCtx != null)
- {
- Interlocked.Increment(ref connectionPool.m_cpCtx.totalAvaliableConnections);
- }
- Interlocked.Increment(ref connectionPool.m_counter.totalAvailable);
- connectionPool.ReleaseSemaphore();
- }
- IL_1D54:
- opoConCtx.opsConCtx = IntPtr.Zero;
- opoConCtx.opsErrCtx = IntPtr.Zero;
- opoConCtx.m_conPooler = null;
- opoConCtx.m_udtDescPoolerByName = null;
- opoConCtx.m_udtDescPoolerByTDO = null;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- if (flag2)
- {
- Interlocked.Decrement(ref this.m_counter.total);
- Interlocked.Increment(ref connectionPool.m_counter.total);
- }
- if ((opoConCtx.bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0)
- {
- if (!this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- this.m_inactive = true;
- }
- }
- else
- {
- if (this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- this.m_inactive = false;
- }
- }
- return num;
- }
- public unsafe void TransactionEnd(object obj)
- {
- int num = 0;
- PooledConCtx pooledConCtx = (PooledConCtx)obj;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(4u, new string[]
- {
- " (MTS) ConnectionPool::TransactionEnd() txnid: (" + pooledConCtx.m_txnid + ")\n"
- });
- }
- if (this.m_cpCtx != null && pooledConCtx.m_txnid != null)
- {
- this.m_cpCtx.m_htTxnIdToIntance.Remove(pooledConCtx.m_txnid);
- }
- pooledConCtx.m_txnid = null;
- if (pooledConCtx != null && (OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
- }
- if (pooledConCtx != null && pooledConCtx.m_promotableTxnManager != null)
- {
- if (pooledConCtx.m_promotableTxnManager.m_bLocalTxnPromoted)
- {
- try
- {
- OpsCon.DelistPromotedTxn(pooledConCtx.opsConCtx);
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- }
- }
- string localTxnIdentifier = pooledConCtx.m_promotableTxnManager.m_localTxnIdentifier;
- if (!string.IsNullOrEmpty(localTxnIdentifier))
- {
- OracleConnection.m_pspePrimaryResourceEntry.Remove(localTxnIdentifier);
- pooledConCtx.m_promotableTxnManager = null;
- }
- }
- else
- {
- pooledConCtx.opoConRefCtx.pITransaction = null;
- try
- {
- num = OpsCon.Enlist(pooledConCtx.opsConCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- num = ErrRes.INT_ERR;
- }
- finally
- {
- if (num != 0)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(4u, new string[]
- {
- " (MTS) ConnectionPool::TransactionEnd(): delistment failure txnid:" + pooledConCtx.m_txnid + "\n"
- });
- }
- try
- {
- if (pooledConCtx.m_fetchArrayPooler != null)
- {
- pooledConCtx.m_fetchArrayPooler.Dispose();
- pooledConCtx.m_fetchArrayPooler = null;
- }
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- lock (pooledConCtx.m_syncObject)
- {
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- if (this.m_clonedCtx.gridCR == 1)
- {
- this.m_conList.Remove(pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (TransactionEnd) Pool Id = ",
- this.m_poolId,
- " Removed PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
- }
- this.UpdateTotalCount(-1, true);
- }
- }
- if (num != 0)
- {
- return;
- }
- }
- if ((pooledConCtx.opoConRefCtx.proxyUserId != null && pooledConCtx.opoConRefCtx.proxyUserId.Length > 0) || pooledConCtx.pOpoConValCtx->OSAuthent == 2)
- {
- OpsCon.CloseProxyAuthUserSession(pooledConCtx.opsConCtx, pooledConCtx.opsErrCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- }
- OpoConCtx opoConCtx = new OpoConCtx();
- opoConCtx.pooledConCtx = pooledConCtx;
- opoConCtx.opsConCtx = pooledConCtx.opsConCtx;
- opoConCtx.opsErrCtx = pooledConCtx.opsErrCtx;
- opoConCtx.pOpoConValCtx = pooledConCtx.pOpoConValCtx;
- opoConCtx.poolName = pooledConCtx.m_poolName;
- opoConCtx.opoConRefCtx = new OpoConRefCtx();
- opoConCtx.opoConRefCtx.serverVersion = pooledConCtx.opoConRefCtx.serverVersion;
- opoConCtx.opoConRefCtx.dataSource = pooledConCtx.opoConRefCtx.dataSource;
- opoConCtx.opoConRefCtx.dbName = pooledConCtx.opoConRefCtx.dbName;
- opoConCtx.opoConRefCtx.hostName = pooledConCtx.opoConRefCtx.hostName;
- opoConCtx.opoConRefCtx.serviceName = pooledConCtx.opoConRefCtx.serviceName;
- opoConCtx.opoConRefCtx.instanceName = pooledConCtx.opoConRefCtx.instanceName;
- opoConCtx.opoConRefCtx.dbDomainName = pooledConCtx.opoConRefCtx.dbDomainName;
- opoConCtx.opoConRefCtx.ttOpsConOpenErrMssg = pooledConCtx.opoConRefCtx.ttOpsConOpenErrMssg;
- opoConCtx.m_conPooler = pooledConCtx.m_conPooler;
- opoConCtx.m_udtDescPoolerByName = pooledConCtx.m_udtDescPoolerByName;
- opoConCtx.m_udtDescPoolerByTDO = pooledConCtx.m_udtDescPoolerByTDO;
- opoConCtx.m_txnid = pooledConCtx.m_txnid;
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- opoConCtx.m_promotableTxnManager = null;
- opoConCtx.pooledConCtx.m_promotableTxnManager = null;
- opoConCtx.m_fetchArrayPooler = pooledConCtx.m_fetchArrayPooler;
- opoConCtx.m_statementData = pooledConCtx.m_statementData;
- opoConCtx.m_totalDataAvailable = pooledConCtx.m_totalDataAvailable;
- if (this.m_bSynchronizeStack)
- {
- lock (this.m_connections)
- {
- this.PutConnection(ref opoConCtx, true, false, false, 1, false, true);
- goto IL_4A9;
- }
- }
- this.PutConnection(ref opoConCtx, true, false, false, 1, false, true);
- IL_4A9:
- opoConCtx = null;
- }
- public void ClearPool(bool bInvalidOnly, bool bRefresh)
- {
- int num = 0;
- int num2 = 0;
- Stack stack = null;
- int num3 = 0;
- Thread.Sleep(100);
- this.m_bSynchronizeStack = true;
- this.m_bClearPoolInProgress = true;
- try
- {
- lock (this.m_connections)
- {
- if (bInvalidOnly)
- {
- stack = Stack.Synchronized(new Stack());
- }
- else
- {
- this.m_clearRequestTimeStamp = DateTime.Now;
- }
- while (this.m_connections.Count > 0)
- {
- int num4 = 0;
- if (this.m_bGridRac && this.m_cpCtx != null)
- {
- try
- {
- num4 = OpsCon.WaitForSingleObject(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 0);
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex);
- }
- num4 = -1;
- }
- if (num4 != 0)
- {
- break;
- }
- Interlocked.Decrement(ref this.m_cpCtx.totalAvaliableConnections);
- }
- int num5 = 0;
- try
- {
- num5 = OpsCon.WaitForSingleObject(this.m_semAvaNumOfCons, 0);
- }
- catch (Exception ex2)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex2);
- }
- num5 = -1;
- }
- if (num5 == 0)
- {
- Interlocked.Decrement(ref this.m_counter.totalAvailable);
- PooledConCtx pooledConCtx = (PooledConCtx)this.m_connections.Pop();
- if (pooledConCtx != null)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfFreeConnections, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfPooledConnections, this.m_clonedCtx);
- }
- }
- try
- {
- if (bInvalidOnly)
- {
- OpsCon.CheckConStatus(pooledConCtx.opsConCtx, pooledConCtx.pOpoConValCtx, pooledConCtx.opsErrCtx, 0, ref num2, 1, 1);
- }
- }
- catch (Exception ex3)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex3);
- }
- num2 = 0;
- }
- finally
- {
- if (num2 == 0)
- {
- try
- {
- try
- {
- if (pooledConCtx.m_fetchArrayPooler != null)
- {
- pooledConCtx.m_fetchArrayPooler.Dispose();
- pooledConCtx.m_fetchArrayPooler = null;
- }
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- lock (pooledConCtx.m_syncObject)
- {
- if (!pooledConCtx.m_bOpsConCtxDisposed)
- {
- if (this.m_clonedCtx.gridCR == 1)
- {
- this.m_conList.Remove(pooledConCtx);
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(16u, new string[]
- {
- string.Concat(new object[]
- {
- " (ClearPool) Pool Id = ",
- this.m_poolId,
- " Removed PooledConCtx= ",
- pooledConCtx.GetHashCode(),
- "\n"
- })
- });
- }
- }
- OpsCon.Dispose(ref pooledConCtx.opsConCtx, ref pooledConCtx.opsErrCtx, ref pooledConCtx.pOpoConValCtx, pooledConCtx.opoConRefCtx);
- pooledConCtx.m_bOpsConCtxDisposed = true;
- }
- }
- }
- }
- catch (Exception ex4)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex4);
- }
- }
- continue;
- }
- finally
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.HardDisconnectsPerSecond) == PerfCounterLevel.HardDisconnectsPerSecond)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.HardDisconnectsPerSecond, this.m_clonedCtx);
- }
- pooledConCtx.opsConCtx = IntPtr.Zero;
- pooledConCtx.opsErrCtx = IntPtr.Zero;
- pooledConCtx.pOpoConValCtx = null;
- pooledConCtx.m_conPooler = null;
- pooledConCtx.m_udtDescPoolerByName = null;
- pooledConCtx.m_udtDescPoolerByTDO = null;
- this.UpdateTotalCount(-1, true);
- num++;
- }
- }
- stack.Push(pooledConCtx);
- }
- }
- else
- {
- if (num4 == 0 && this.m_bGridRac && this.m_cpCtx != null)
- {
- try
- {
- OpsCon.ReleaseSemaphore(this.m_cpCtx.m_semCPCtxAvaNumOfCons, 1, ref num3);
- }
- catch (Exception ex5)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.TraceExceptionInfo(ex5);
- }
- }
- Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
- break;
- }
- break;
- }
- }
- if (stack != null && stack.Count > 0)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfFreeConnections) == PerfCounterLevel.NumberOfFreeConnections)
- {
- ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfFreeConnections, stack.Count - this.m_connections.Count, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfPooledConnections) == PerfCounterLevel.NumberOfPooledConnections)
- {
- ConnectionPool.PerformanceCounterIncrementBy(OraclePerfParams.CounterIndex.NumberOfPooledConnections, stack.Count - this.m_connections.Count, this.m_clonedCtx);
- }
- this.m_connections = stack;
- for (int i = 0; i < stack.Count; i++)
- {
- if (this.m_bGridRac && this.m_cpCtx != null)
- {
- Interlocked.Increment(ref this.m_cpCtx.totalAvaliableConnections);
- }
- Interlocked.Increment(ref this.m_counter.totalAvailable);
- this.ReleaseSemaphore();
- }
- }
- if (this.m_bGridRac)
- {
- Interlocked.Add(ref this.m_cpCtx.m_consFromAppToClear, this.m_cpCtx.m_counter.total);
- }
- else
- {
- Interlocked.Add(ref this.m_consFromAppToClear, this.m_counter.total);
- }
- }
- }
- finally
- {
- this.m_bSynchronizeStack = false;
- }
- if ((this.m_bGridRac ? this.m_cpCtx.m_counter.total : this.m_counter.total) == 0 && !this.m_inactive)
- {
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfActiveConnectionPools) == PerfCounterLevel.NumberOfActiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterDecrement(OraclePerfParams.CounterIndex.NumberOfActiveConnectionPools, this.m_clonedCtx);
- }
- if ((OraTrace.m_PerformanceCounters & PerfCounterLevel.NumberOfInactiveConnectionPools) == PerfCounterLevel.NumberOfInactiveConnectionPools)
- {
- ConnectionPool.PerformanceCounterIncrement(OraclePerfParams.CounterIndex.NumberOfInactiveConnectionPools, this.m_clonedCtx);
- }
- this.m_inactive = true;
- }
- }
- private void PushToResourcePool(OpoConCtx opoConCtx, PooledConCtx pooledConCtx)
- {
- pooledConCtx.m_txnid = opoConCtx.m_txnid;
- this.m_oraResPool.PutResource(opoConCtx.m_systemTransaction, pooledConCtx);
- opoConCtx.m_systemTransaction = null;
- opoConCtx.m_txnType = TxnType.None;
- }
- private void UpdateAgentRecommendations(OracleTuningAgent.RecommendationType recommendationType, object recommendation)
- {
- try
- {
- if (recommendationType == OracleTuningAgent.RecommendationType.SCS)
- {
- this.m_scsRecommendations = (int)recommendation;
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(64u, new string[]
- {
- string.Concat(new object[]
- {
- " (TUNING) ConnectionPool::UpdateAgentRecommendations(): SCS recommendations for pool with Id: ",
- this.m_poolId,
- "; Change to ",
- this.m_scsRecommendations.ToString(),
- " \n"
- })
- });
- }
- }
- }
- catch (Exception ex)
- {
- if (OraTrace.m_TraceLevel != 0u)
- {
- OraTrace.Trace(64u, new string[]
- {
- string.Concat(new object[]
- {
- " (ERROR) ConnectionPool::UpdateAgentRecommendations(): Pool Id: ",
- this.m_poolId,
- "; Exception: ",
- ex.ToString(),
- " \n"
- })
- });
- }
- }
- }
- private void IncrementStmtSamplesLimit()
- {
- this.m_stmtSamplesLimit += 100;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement