Esempio n. 1
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);
        }
Esempio n. 2
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);
     }
 }
 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);
         }
     }
 }
 internal override void OpenConnection(DbConnection outerConnection, System.Data.ProviderBase.DbConnectionFactory connectionFactory)
 {
     if (connectionFactory.SetInnerConnectionFrom(outerConnection, System.Data.ProviderBase.DbConnectionClosedConnecting.SingletonInstance, this))
     {
         System.Data.ProviderBase.DbConnectionInternal to = null;
         try
         {
             connectionFactory.PermissionDemand(outerConnection);
             to = connectionFactory.GetConnection(outerConnection);
         }
         catch
         {
             connectionFactory.SetInnerConnectionTo(outerConnection, this);
             throw;
         }
         if (to == null)
         {
             connectionFactory.SetInnerConnectionTo(outerConnection, this);
             throw System.Data.Common.ADP.InternalConnectionError(System.Data.Common.ADP.ConnectionError.GetConnectionReturnsNull);
         }
         connectionFactory.SetInnerConnectionEvent(outerConnection, to);
     }
 }
Esempio n. 5
0
 internal override void OpenConnection(DbConnection outerConnection, System.Data.ProviderBase.DbConnectionFactory connectionFactory)
 {
     throw System.Data.Common.ADP.ConnectionAlreadyOpen(base.State);
 }
 protected internal override DataTable GetSchema(System.Data.ProviderBase.DbConnectionFactory factory, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions)
 {
     throw System.Data.Common.ADP.ClosedConnectionError();
 }
 internal override void CloseConnection(DbConnection owningObject, System.Data.ProviderBase.DbConnectionFactory connectionFactory)
 {
 }
 protected internal virtual DataTable GetSchema(System.Data.ProviderBase.DbConnectionFactory factory, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions)
 {
     return(factory.GetMetaDataFactory(poolGroup, this).GetSchema(outerConnection, collectionName, restrictions));
 }