コード例 #1
0
 internal void MakeNonPooledObject(object owningObject, System.Data.ProviderBase.DbConnectionPoolCounters performanceCounters)
 {
     this._connectionPool      = null;
     this._performanceCounters = performanceCounters;
     this._owningObject.Target = owningObject;
     this._pooledCount         = -1;
 }
コード例 #2
0
        internal System.Data.ProviderBase.DbConnectionPool GetConnectionPool(System.Data.ProviderBase.DbConnectionFactory connectionFactory)
        {
            object obj2 = null;

            if (this._poolGroupOptions != null)
            {
                System.Data.ProviderBase.DbConnectionPoolIdentity noIdentity = System.Data.ProviderBase.DbConnectionPoolIdentity.NoIdentity;
                if (this._poolGroupOptions.PoolByIdentity)
                {
                    noIdentity = System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent();
                    if (noIdentity.IsRestricted)
                    {
                        noIdentity = null;
                    }
                }
                if (noIdentity != null)
                {
                    obj2 = this._poolCollection[noIdentity];
                    if (obj2 == null)
                    {
                        System.Data.ProviderBase.DbConnectionPoolProviderInfo connectionPoolProviderInfo = connectionFactory.CreateConnectionPoolProviderInfo(this.ConnectionOptions);
                        System.Data.ProviderBase.DbConnectionPool             pool = new System.Data.ProviderBase.DbConnectionPool(connectionFactory, this, noIdentity, connectionPoolProviderInfo);
                        lock (this)
                        {
                            HybridDictionary dictionary = this._poolCollection;
                            obj2 = dictionary[noIdentity];
                            if ((obj2 == null) && this.MarkPoolGroupAsActive())
                            {
                                pool.Startup();
                                HybridDictionary dictionary2 = new HybridDictionary(1 + dictionary.Count, false);
                                foreach (DictionaryEntry entry in dictionary)
                                {
                                    dictionary2.Add(entry.Key, entry.Value);
                                }
                                dictionary2.Add(noIdentity, pool);
                                connectionFactory.PerformanceCounters.NumberOfActiveConnectionPools.Increment();
                                this._poolCollection = dictionary2;
                                this._poolCount      = dictionary2.Count;
                                obj2 = pool;
                                pool = null;
                            }
                        }
                        if (pool != null)
                        {
                            pool.Shutdown();
                        }
                    }
                }
            }
            if (obj2 == null)
            {
                lock (this)
                {
                    this.MarkPoolGroupAsActive();
                }
            }
            return((System.Data.ProviderBase.DbConnectionPool)obj2);
        }
コード例 #3
0
 internal void CleanupConnectionOnTransactionCompletion(Transaction transaction)
 {
     this.DetachTransaction(transaction, false);
     System.Data.ProviderBase.DbConnectionPool pool = this.Pool;
     if (pool != null)
     {
         pool.TransactionEnded(transaction, this);
     }
 }
コード例 #4
0
 internal void QueuePoolForRelease(System.Data.ProviderBase.DbConnectionPool pool, bool clearing)
 {
     pool.Shutdown();
     lock (this._poolsToRelease)
     {
         if (clearing)
         {
             pool.Clear();
         }
         this._poolsToRelease.Add(pool);
     }
     this.PerformanceCounters.NumberOfInactiveConnectionPools.Increment();
 }
コード例 #5
0
        public virtual void Dispose()
        {
            this._connectionPool              = null;
            this._performanceCounters         = null;
            this._connectionIsDoomed          = true;
            this._enlistedTransactionOriginal = null;
            Transaction transaction = Interlocked.Exchange <Transaction>(ref this._enlistedTransaction, null);

            if (transaction != null)
            {
                transaction.Dispose();
            }
        }
コード例 #6
0
 private bool ClearInternal(bool clearing)
 {
     lock (this)
     {
         HybridDictionary dictionary2 = this._poolCollection;
         if (0 < dictionary2.Count)
         {
             HybridDictionary dictionary = new HybridDictionary(dictionary2.Count, false);
             foreach (DictionaryEntry entry in dictionary2)
             {
                 if (entry.Value != null)
                 {
                     System.Data.ProviderBase.DbConnectionPool pool = (System.Data.ProviderBase.DbConnectionPool)entry.Value;
                     if (clearing || (!pool.ErrorOccurred && (pool.Count == 0)))
                     {
                         System.Data.ProviderBase.DbConnectionFactory connectionFactory = pool.ConnectionFactory;
                         connectionFactory.PerformanceCounters.NumberOfActiveConnectionPools.Decrement();
                         connectionFactory.QueuePoolForRelease(pool, clearing);
                     }
                     else
                     {
                         dictionary.Add(entry.Key, entry.Value);
                     }
                 }
             }
             this._poolCollection = dictionary;
             this._poolCount      = dictionary.Count;
         }
         if (!clearing && (this._poolCount == 0))
         {
             if (1 == this._state)
             {
                 this._state = 2;
                 Bid.Trace("<prov.DbConnectionPoolGroup.ClearInternal|RES|INFO|CPOOL> %d#, Idle\n", this.ObjectID);
             }
             else if (2 == this._state)
             {
                 this._state = 4;
                 Bid.Trace("<prov.DbConnectionPoolGroup.ReadyToRemove|RES|INFO|CPOOL> %d#, Disabled\n", this.ObjectID);
             }
         }
         return(4 == this._state);
     }
 }
コード例 #7
0
 internal virtual void CloseConnection(DbConnection owningObject, System.Data.ProviderBase.DbConnectionFactory connectionFactory)
 {
     Bid.PoolerTrace("<prov.DbConnectionInternal.CloseConnection|RES|CPOOL> %d# Closing.\n", this.ObjectID);
     if (connectionFactory.SetInnerConnectionFrom(owningObject, System.Data.ProviderBase.DbConnectionOpenBusy.SingletonInstance, this))
     {
         try
         {
             System.Data.ProviderBase.DbConnectionPool pool = this.Pool;
             Transaction enlistedTransaction = this.EnlistedTransaction;
             if ((null != enlistedTransaction) && (enlistedTransaction.TransactionInformation.Status != TransactionStatus.Active))
             {
                 this.DetachTransaction(enlistedTransaction, true);
             }
             if (pool != null)
             {
                 pool.PutObject(this, owningObject);
             }
             else
             {
                 this.Deactivate();
                 this.PerformanceCounters.HardDisconnectsPerSecond.Increment();
                 this._owningObject.Target = null;
                 if (this.IsTransactionRoot)
                 {
                     this.SetInStasis();
                 }
                 else
                 {
                     this.PerformanceCounters.NumberOfNonPooledConnections.Decrement();
                     this.Dispose();
                 }
             }
         }
         finally
         {
             connectionFactory.SetInnerConnectionEvent(owningObject, System.Data.ProviderBase.DbConnectionClosedPreviouslyOpened.SingletonInstance);
         }
     }
 }
コード例 #8
0
 internal virtual void DelegatedTransactionEnded()
 {
     Bid.Trace("<prov.DbConnectionInternal.DelegatedTransactionEnded|RES|CPOOL> %d#, Delegated Transaction Completed.\n", this.ObjectID);
     if (1 == this._pooledCount)
     {
         this.TerminateStasis(true);
         this.Deactivate();
         System.Data.ProviderBase.DbConnectionPool pool = this.Pool;
         if (pool == null)
         {
             throw System.Data.Common.ADP.InternalError(System.Data.Common.ADP.InternalErrorCode.PooledObjectWithoutPool);
         }
         pool.PutObjectFromTransactedPool(this);
     }
     else if ((-1 == this._pooledCount) && !this._owningObject.IsAlive)
     {
         this.TerminateStasis(false);
         this.Deactivate();
         this.PerformanceCounters.NumberOfNonPooledConnections.Decrement();
         this.Dispose();
     }
 }
コード例 #9
0
        internal System.Data.ProviderBase.DbConnectionInternal GetConnection(DbConnection owningConnection)
        {
            System.Data.ProviderBase.DbConnectionInternal connection;
            int num2 = 10;
            int millisecondsTimeout = 1;

            do
            {
                System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup = this.GetConnectionPoolGroup(owningConnection);
                System.Data.ProviderBase.DbConnectionPool      connectionPool      = this.GetConnectionPool(owningConnection, connectionPoolGroup);
                if (connectionPool == null)
                {
                    connectionPoolGroup = this.GetConnectionPoolGroup(owningConnection);
                    connection          = this.CreateNonPooledConnection(owningConnection, connectionPoolGroup);
                    this.PerformanceCounters.NumberOfNonPooledConnections.Increment();
                }
                else
                {
                    connection = connectionPool.GetConnection(owningConnection);
                    if (connection == null)
                    {
                        if (connectionPool.IsRunning)
                        {
                            Bid.Trace("<prov.DbConnectionFactory.GetConnection|RES|CPOOL> %d#, GetConnection failed because a pool timeout occurred.\n", this.ObjectID);
                            throw System.Data.Common.ADP.PooledOpenTimeout();
                        }
                        Thread.Sleep(millisecondsTimeout);
                        millisecondsTimeout *= 2;
                    }
                }
            }while ((connection == null) && (num2-- > 0));
            if (connection == null)
            {
                Bid.Trace("<prov.DbConnectionFactory.GetConnection|RES|CPOOL> %d#, GetConnection failed because a pool timeout occurred and all retries were exhausted.\n", this.ObjectID);
                throw System.Data.Common.ADP.PooledOpenTimeout();
            }
            return(connection);
        }
コード例 #10
0
 protected abstract System.Data.ProviderBase.DbConnectionInternal CreateConnection(System.Data.Common.DbConnectionOptions options, object poolGroupProviderInfo, System.Data.ProviderBase.DbConnectionPool pool, DbConnection owningConnection);
コード例 #11
0
 internal System.Data.ProviderBase.DbConnectionInternal CreatePooledConnection(DbConnection owningConnection, System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnectionOptions options)
 {
     System.Data.ProviderBase.DbConnectionPoolGroupProviderInfo providerInfo = pool.PoolGroup.ProviderInfo;
     System.Data.ProviderBase.DbConnectionInternal internal2 = this.CreateConnection(options, providerInfo, pool, owningConnection);
     if (internal2 != null)
     {
         this.PerformanceCounters.HardConnectsPerSecond.Increment();
         internal2.MakePooledConnection(pool);
     }
     Bid.Trace("<prov.DbConnectionFactory.CreatePooledConnection|RES|CPOOL> %d#, Pooled database connection created.\n", this.ObjectID);
     return(internal2);
 }
 internal System.Data.ProviderBase.DbConnectionPool GetConnectionPool(System.Data.ProviderBase.DbConnectionFactory connectionFactory)
 {
     object obj2 = null;
     if (this._poolGroupOptions != null)
     {
         System.Data.ProviderBase.DbConnectionPoolIdentity noIdentity = System.Data.ProviderBase.DbConnectionPoolIdentity.NoIdentity;
         if (this._poolGroupOptions.PoolByIdentity)
         {
             noIdentity = System.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrent();
             if (noIdentity.IsRestricted)
             {
                 noIdentity = null;
             }
         }
         if (noIdentity != null)
         {
             obj2 = this._poolCollection[noIdentity];
             if (obj2 == null)
             {
                 System.Data.ProviderBase.DbConnectionPoolProviderInfo connectionPoolProviderInfo = connectionFactory.CreateConnectionPoolProviderInfo(this.ConnectionOptions);
                 System.Data.ProviderBase.DbConnectionPool pool = new System.Data.ProviderBase.DbConnectionPool(connectionFactory, this, noIdentity, connectionPoolProviderInfo);
                 lock (this)
                 {
                     HybridDictionary dictionary = this._poolCollection;
                     obj2 = dictionary[noIdentity];
                     if ((obj2 == null) && this.MarkPoolGroupAsActive())
                     {
                         pool.Startup();
                         HybridDictionary dictionary2 = new HybridDictionary(1 + dictionary.Count, false);
                         foreach (DictionaryEntry entry in dictionary)
                         {
                             dictionary2.Add(entry.Key, entry.Value);
                         }
                         dictionary2.Add(noIdentity, pool);
                         connectionFactory.PerformanceCounters.NumberOfActiveConnectionPools.Increment();
                         this._poolCollection = dictionary2;
                         this._poolCount = dictionary2.Count;
                         obj2 = pool;
                         pool = null;
                     }
                 }
                 if (pool != null)
                 {
                     pool.Shutdown();
                 }
             }
         }
     }
     if (obj2 == null)
     {
         lock (this)
         {
             this.MarkPoolGroupAsActive();
         }
     }
     return (System.Data.ProviderBase.DbConnectionPool) obj2;
 }
 internal void MakePooledConnection(System.Data.ProviderBase.DbConnectionPool connectionPool)
 {
     this._createTime = DateTime.UtcNow;
     this._connectionPool = connectionPool;
     this._performanceCounters = connectionPool.PerformanceCounters;
 }
 internal void MakeNonPooledObject(object owningObject, System.Data.ProviderBase.DbConnectionPoolCounters performanceCounters)
 {
     this._connectionPool = null;
     this._performanceCounters = performanceCounters;
     this._owningObject.Target = owningObject;
     this._pooledCount = -1;
 }
 public virtual void Dispose()
 {
     this._connectionPool = null;
     this._performanceCounters = null;
     this._connectionIsDoomed = true;
     this._enlistedTransactionOriginal = null;
     Transaction transaction = Interlocked.Exchange<Transaction>(ref this._enlistedTransaction, null);
     if (transaction != null)
     {
         transaction.Dispose();
     }
 }
コード例 #16
0
 internal void MakePooledConnection(System.Data.ProviderBase.DbConnectionPool connectionPool)
 {
     this._createTime          = DateTime.UtcNow;
     this._connectionPool      = connectionPool;
     this._performanceCounters = connectionPool.PerformanceCounters;
 }