From: Michael D. <mik...@us...> - 2004-09-01 03:28:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14322/Connection Modified Files: ConnectionProvider.cs DriverConnectionProvider.cs Log Message: Removed ConnectionPool from ConnectionProvider and settings for PreparedStatementCache. Index: DriverConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/DriverConnectionProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DriverConnectionProvider.cs 18 Jun 2004 13:59:05 -0000 1.2 --- DriverConnectionProvider.cs 1 Sep 2004 03:28:28 -0000 1.3 *************** *** 10,24 **** /// A ConnectionProvider that uses an IDriver to create connections. /// </summary> - /// <remarks> - /// This IConnectionProvider implements a rudimentary connection pool. - /// </remarks> public class DriverConnectionProvider : ConnectionProvider { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DriverConnectionProvider)); - private static object poolLock = new object(); - private readonly ArrayList pool = new ArrayList(); - private int checkedOut = 0; - public DriverConnectionProvider() { --- 10,17 ---- *************** *** 28,50 **** public override IDbConnection GetConnection() { - if(log.IsDebugEnabled) log.Debug("total checked-out connections: " + checkedOut); - - lock(poolLock) - { - if( pool.Count > 0 ) - { - int last = pool.Count - 1; - if(log.IsDebugEnabled) - { - log.Debug("using pooled connection, pool size: " + last); - checkedOut++; - } - - IDbConnection conn = (IDbConnection)pool[last]; - pool.RemoveAt(last); - return conn; - } - } - log.Debug("Obtaining IDbConnection from Driver"); try --- 21,24 ---- *************** *** 69,104 **** { log.Info("cleaning up connection pool"); - - for(int i = 0; i < pool.Count; i++) - { - try - { - ((IDbConnection)pool[i]).Close(); - } - catch(Exception e) - { - log.Warn("problem closing pooled connection", e); - } - } - - pool.Clear(); } public override void CloseConnection(IDbConnection conn) { - if(log.IsDebugEnabled) checkedOut--; - - lock(poolLock) - { - int currentSize = pool.Count; - if( currentSize < PoolSize ) - { - if(log.IsDebugEnabled) log.Debug("returning connection to pool, pool size: " + (currentSize + 1) ); - pool.Add(conn); - return; - } - } - base.CloseConnection(conn); } --- 43,53 ---- { log.Info("cleaning up connection pool"); } public override void CloseConnection(IDbConnection conn) { base.CloseConnection(conn); + //TODO: make sure I want to do this - pretty sure I do because of Oracle problems. + conn.Dispose(); } Index: ConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/ConnectionProvider.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConnectionProvider.cs 28 Aug 2004 04:14:01 -0000 1.6 --- ConnectionProvider.cs 1 Sep 2004 03:28:28 -0000 1.7 *************** *** 15,19 **** private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ConnectionProvider)); private string connString = null; - private int poolSize; protected IDriver driver = null; --- 15,18 ---- *************** *** 40,50 **** log.Info( "Configuring ConnectionProvider" ); - // default the poolSize to 0 if no setting was made because most of the .net DataProvider - // do their own connection pooling. This would be useful to change to some higher number - // if the .net DataProvider did not provide their own connection pooling. I don't know of - // any instances of this yet. - poolSize = PropertiesHelper.GetInt32( Cfg.Environment.PoolSize, settings, 0 ); - log.Info( "NHibernate connection pool size: " + poolSize ); - connString = settings[ Cfg.Environment.ConnectionString ] as string; if (connString==null) --- 39,42 ---- *************** *** 87,95 **** } - protected virtual int PoolSize - { - get { return poolSize; } - } - public IDriver Driver { --- 79,82 ---- |