Summary description for BaseDriver.
Inheritance: IDisposable
Ejemplo n.º 1
0
		public MySqlField(Driver driver)
		{
			this.driver = driver;
			connVersion = driver.Version;
			maxLength = 1;
			binaryOk = true;
		}
        public static void ReleaseConnection(Driver driver)
        {
            Debug.Assert(driver != null);

			MySqlPool pool = driver.Pool;
			if (pool == null) return;
			
            pool.ReleaseConnection(driver);
        }
Ejemplo n.º 3
0
        public static void ReleaseConnection(Driver driver)
        {
            string key = driver.Settings.GetConnectionString(true);
            MySqlPool pool = (MySqlPool) pools[key];

            // if we can't find the pool but we did get a thread id then we assume
            // something is bad wrong.  If we didn't get a thread id then we assume that
            // the driver connection info was bogus and that led to the pool failing
            // to create
            if (pool == null)
            {
                if (driver.ThreadID != -1)
                    throw new MySqlException("Pooling exception: Unable to find original pool for connection");
            }
            else
                pool.ReleaseConnection(driver);
        }
Ejemplo n.º 4
0
 private void EnqueueIdle(Driver driver)
 {
   driver.IdleSince = DateTime.Now;
   idlePool.Enqueue(driver);
 }
Ejemplo n.º 5
0
    /// <summary>
    /// Removes a connection from the in use pool.  The only situations where this method 
    /// would be called are when a connection that is in use gets some type of fatal exception
    /// or when the connection is being returned to the pool and it's too old to be 
    /// returned.
    /// </summary>
    /// <param name="driver"></param>
    public void RemoveConnection(Driver driver)
    {
      lock ((inUsePool as ICollection).SyncRoot)
      {
        if (inUsePool.Contains(driver))
        {
          inUsePool.Remove(driver);
          Interlocked.Increment(ref available);
          autoEvent.Set();
        }
      }

      // if we are being cleared and we are out of connections then have
      // the manager destroy us.
      if (beingCleared && NumConnections == 0)
        MySqlPoolManager.RemoveClearedPool(this);
    }
Ejemplo n.º 6
0
    public void ReleaseConnection(Driver driver)
    {
      lock ((inUsePool as ICollection).SyncRoot)
      {
        if (inUsePool.Contains(driver))
          inUsePool.Remove(driver);
      }

      if (driver.ConnectionLifetimeExpired() || beingCleared)
      {
        driver.Close();
        Debug.Assert(!idlePool.Contains(driver));
      }
      else
      {
        lock ((idlePool as ICollection).SyncRoot)
        {
          EnqueueIdle(driver);
        }
      }

      Interlocked.Increment(ref available);
      autoEvent.Set();
    }
Ejemplo n.º 7
0
 public NativeDriver(Driver owner)
 {
   this.owner = owner;
   threadId = -1;
 }
Ejemplo n.º 8
0
        public static Driver Create(MySqlConnectionStringBuilder settings)
        {
            Driver d = null;
#if !CF
            try
            {
                if (MySqlTrace.QueryAnalysisEnabled || settings.Logging || settings.UseUsageAdvisor)
                    d = new TracingDriver(settings);
            }
            catch (TypeInitializationException ex)
            {
                if (!(ex.InnerException is SecurityException))
                    throw ex;
                //Only rethrow if InnerException is not a SecurityException. If it is a SecurityException then 
                //we couldn't initialize MySqlTrace because we don't have unmanaged code permissions. 
            }
#endif
            if ( d == null )
                d = new Driver(settings);

            d.Open();
            return d;
        }
Ejemplo n.º 9
0
    public static Driver Create(MySqlConnectionStringBuilder settings)
    {
      Driver d = null;
#if !CF && !RT
      try
      {
        if (MySqlTrace.QueryAnalysisEnabled || settings.Logging || settings.UseUsageAdvisor)
          d = new TracingDriver(settings);
      }
      catch (TypeInitializationException ex)
      {
        if (!(ex.InnerException is SecurityException))
          throw ex;
        //Only rethrow if InnerException is not a SecurityException. If it is a SecurityException then 
        //we couldn't initialize MySqlTrace because we don't have unmanaged code permissions. 
      }
#else
      if (settings.Logging || settings.UseUsageAdvisor)
      {
        throw new NotImplementedException( "Logging not supported in this WinRT release." );
      }
#endif
      if (d == null)
        d = new Driver(settings);

      //this try was added as suggested fix submitted on MySql Bug 72025, socket connections are left in CLOSE_WAIT status when connector fails to open a new connection.
      //the bug is present when the client try to get more connections that the server support or has configured in the max_connections variable.
      try
      {
        d.Open();
      }
      catch
      {
        d.Dispose();
        throw;
      }
      return d;
    }
Ejemplo n.º 10
0
        public static Driver Create(MySqlConnectionStringBuilder settings)
        {
            Driver d = null;

            #if !CF
            if (settings.Logging || settings.UseUsageAdvisor)
                d = new TracingDriver(settings);
            else
            #endif
                d = new Driver(settings);
            d.Open();
            return d;
        }
Ejemplo n.º 11
0
        public static Driver Create(MySqlConnectionStringBuilder settings)
        {
            Driver d = new Driver(settings);

            //this try was added as suggested fix submitted on MySql Bug 72025, socket connections are left in CLOSE_WAIT status when connector fails to open a new connection.
            //the bug is present when the client try to get more connections that the server support or has configured in the max_connections variable.
            try
            {
                d.Open();
            }
            catch
            {
                d.Dispose();
                throw;
            }
            return d;
        }
Ejemplo n.º 12
0
    public static void RemoveConnection(Driver driver)
    {
      Debug.Assert(driver != null);

      var pool = driver.Pool;
      if (pool == null) return;

      pool.RemoveConnection(driver);
    }