[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source PgCommandBuilder.cs,1.16,1.
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4055 Modified Files: PgCommandBuilder.cs PgConnection.cs PgConnectionPool.cs PgDbConnection.cs Log Message: 2004-03-08 Carlos Guzman Alvarez <car...@te...> * Mono.Security.Protocol.Tls/SslClientStream.cs: * Mono.Security.Protocol.Tls/SslServerStream.cs: - Callback cleanup. * PostgreSql.Data.PgSqlClient/PgCommandBuilder.cs: - Cleanup * PostgreSql.Data.PgSqlClient/PgConnectionPool.cs: - New connection pool implementation. * PostgreSql.Data.PgSqlClient/PgConnection.cs: * PostgreSql.Data.PgSqlClient/PgDbConnection.cs: * PostgreSql.Data.PgSqlClient/NPgClient/PgDbClient.cs: - Reworked SSL events hacks. Index: PgCommandBuilder.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommandBuilder.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PgCommandBuilder.cs 9 Feb 2004 14:19:22 -0000 1.16 --- PgCommandBuilder.cs 8 Mar 2004 15:12:26 -0000 1.17 *************** *** 756,765 **** break; } - - if (e.Command != null && e.Row != null) - { - e.Row.AcceptChanges(); - e.Status = UpdateStatus.Continue; - } } catch (Exception exception) --- 756,759 ---- Index: PgConnection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnection.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PgConnection.cs 6 Mar 2004 14:42:00 -0000 1.13 --- PgConnection.cs 8 Mar 2004 15:12:26 -0000 1.14 *************** *** 378,384 **** dbConnection = new PgDbConnection(connectionString); if (dbConnection.Settings.Pooling) { ! dbConnection = PgConnectionPool.GetConnection(connectionString); } else --- 378,390 ---- dbConnection = new PgDbConnection(connectionString); + // Add handler for Ssl connections + dbConnection.DB.SslConnectionDelegate = new SslConnectionCallback(this.OnSslConnection); + + // Open connection if (dbConnection.Settings.Pooling) { ! dbConnection = PgConnectionPool.GetConnection( ! connectionString, ! dbConnection); } else *************** *** 405,424 **** notificationHandler = new PgClientNotificationEventHandler(OnNotification); dbConnection.DB.Notification += notificationHandler; - - // If we are working with SSL add event handlers - if (this.dbConnection.Settings.SSL) - { - // Server certificate validation - certificateValidationCallback = new CertificateValidationCallback(OnServerCertificateValidation); - dbConnection.DB.SslClientStream.ServerCertValidationDelegate = certificateValidationCallback; - - // Client certificate selection - certificateSelectionCallback = new CertificateSelectionCallback(OnClientCertificateSelection); - dbConnection.DB.SslClientStream.ClientCertSelectionDelegate = certificateSelectionCallback; - - // Private key selection - privateKeySelectionCallback = new PrivateKeySelectionCallback(OnPrivateKeySelection); - dbConnection.DB.SslClientStream.PrivateKeyCertSelectionDelegate = privateKeySelectionCallback; - } } catch (PgClientException ex) --- 411,414 ---- *************** *** 677,680 **** --- 667,684 ---- } + private void OnSslConnection() + { + // Server certificate validation + certificateValidationCallback = new CertificateValidationCallback(OnServerCertificateValidation); + dbConnection.DB.SslClientStream.ServerCertValidationDelegate = certificateValidationCallback; + + // Client certificate selection + certificateSelectionCallback = new CertificateSelectionCallback(OnClientCertificateSelection); + dbConnection.DB.SslClientStream.ClientCertSelectionDelegate = certificateSelectionCallback; + + // Private key selection + privateKeySelectionCallback = new PrivateKeySelectionCallback(OnPrivateKeySelection); + dbConnection.DB.SslClientStream.PrivateKeyCertSelectionDelegate = privateKeySelectionCallback; + } #endregion Index: PgConnectionPool.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnectionPool.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgConnectionPool.cs 9 Feb 2004 14:19:22 -0000 1.4 --- PgConnectionPool.cs 8 Mar 2004 15:12:26 -0000 1.5 *************** *** 1,19 **** ! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation; either ! * version 2.1 of the License, or (at your option) any later version. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ using System; --- 1,19 ---- ! // ! // Firebird .NET Data Provider - Firebird managed data provider for .NET and Mono ! // Copyright (C) 2002-2004 Carlos Guzman Alvarez ! // ! // Distributable under LGPL license. ! // You may obtain a copy of the License at http://www.gnu.org/copyleft/lesser.html ! // ! // This library is free software; you can redistribute it and/or ! // modify it under the terms of the GNU Lesser General Public ! // License as published by the Free Software Foundation; either ! // version 2.1 of the License, or (at your option) any later version. ! // ! // This library is distributed in the hope that it will be useful, ! // but WITHOUT ANY WARRANTY; without even the implied warranty of ! // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! // Lesser General Public License for more details. ! // using System; *************** *** 21,25 **** using System.Collections; using System.Threading; - using PostgreSql.Data.NPgClient; namespace PostgreSql.Data.PgSqlClient --- 21,24 ---- *************** *** 27,53 **** internal class PgConnectionPool : MarshalByRefObject { ! #region Fields ! private static PgPoolManager pool = null; #endregion ! #region Methods ! public static void Initialize() { if (pool == null) { ! pool = new PgPoolManager(); } } ! ! public static PgDbConnection GetConnection(string connectionString) { ! Initialize(); ! return ((PgDbConnection)pool.CheckOut(connectionString)); } ! public static void FreeConnection(PgDbConnection c) { --- 26,52 ---- internal class PgConnectionPool : MarshalByRefObject { ! #region FIELDS ! private static ConnectionPool pool = null; #endregion ! #region METHODS ! public static void Init() { if (pool == null) { ! pool = new ConnectionPool(); } } ! ! public static PgDbConnection GetConnection(string connectionString, PgDbConnection connection) { ! Init(); ! return ((PgDbConnection)pool.CheckOut(connectionString, connection)); } ! public static void FreeConnection(PgDbConnection c) { *************** *** 58,64 **** } ! internal class PgPoolManager { ! #region Fields private ArrayList locked; --- 57,63 ---- } ! internal class ConnectionPool { ! #region FIELDS private ArrayList locked; *************** *** 68,74 **** #endregion ! #region Constructors ! public PgPoolManager() { locked = ArrayList.Synchronized(new ArrayList()); --- 67,73 ---- #endregion ! #region CONSTRUCTORS ! public ConnectionPool() { locked = ArrayList.Synchronized(new ArrayList()); *************** *** 83,91 **** #endregion ! #region Methods public PgDbConnection CheckOut(string connectionString) { ! PgDbConnection newConnection = null; long now = System.DateTime.Now.Ticks; --- 82,95 ---- #endregion ! #region METHODS public PgDbConnection CheckOut(string connectionString) { ! return this.CheckOut(connectionString, null); ! } ! ! public PgDbConnection CheckOut(string connectionString, PgDbConnection instance) ! { ! PgDbConnection newConnection = null; long now = System.DateTime.Now.Ticks; *************** *** 97,101 **** unlocked.CopyTo(0, list, 0, list.Length); ! foreach(PgDbConnection connection in list) { if (Validate(connection, connectionString)) --- 101,105 ---- unlocked.CopyTo(0, list, 0, list.Length); ! foreach (PgDbConnection connection in list) { if (Validate(connection, connectionString)) *************** *** 132,136 **** } ! newConnection = Create(connectionString); newConnection.Created = System.DateTime.Now.Ticks; --- 136,149 ---- } ! if (instance == null) ! { ! newConnection = Create(connectionString); ! } ! else ! { ! newConnection = instance; ! newConnection.Connect(); ! } ! newConnection.Pooled = true; newConnection.Created = System.DateTime.Now.Ticks; *************** *** 143,147 **** public void CheckIn(PgDbConnection connection) { ! lock (typeof(PgDbConnection)) { connection.Created = System.DateTime.Now.Ticks; --- 156,160 ---- public void CheckIn(PgDbConnection connection) { ! lock (typeof(PgConnectionPool)) { connection.Created = System.DateTime.Now.Ticks; *************** *** 170,178 **** PgDbConnection connection = new PgDbConnection(connectionString); connection.Connect(); - connection.Pooled = true; return connection; } ! catch (PgClientException ex) { throw ex; --- 183,190 ---- PgDbConnection connection = new PgDbConnection(connectionString); connection.Connect(); return connection; } ! catch (Exception ex) { throw ex; *************** *** 184,189 **** try { ! return (connection.ConnectionString == connectionString && ! connection.VerifyConnection()); } catch (Exception ex) --- 196,201 ---- try { ! return (connection.ConnectionString == connectionString && ! connection.Verify()); } catch (Exception ex) *************** *** 197,201 **** try { ! if (connection.VerifyConnection()) { connection.Disconnect(); --- 209,213 ---- try { ! if (connection.Verify()) { connection.Disconnect(); *************** *** 210,214 **** private void CleanUp(object State) { ! long now = System.DateTime.Now.Ticks; lock (unlocked.SyncRoot) --- 222,226 ---- private void CleanUp(object State) { ! long now = System.DateTime.Now.Ticks; lock (unlocked.SyncRoot) Index: PgDbConnection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgDbConnection.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PgDbConnection.cs 12 Feb 2004 19:50:41 -0000 1.7 --- PgDbConnection.cs 8 Mar 2004 15:12:26 -0000 1.8 *************** *** 44,74 **** public PgDbClient DB { ! get { return db; } } public string ConnectionString { ! get { return connectionString; } } public long Lifetime { ! get { return lifetime; } } public long Created { ! get { return created; } ! set { created = value; } } public bool Pooled { ! get { return pooled; } ! set { pooled = value; } } public PgConnectionParams Settings { ! get { return settings; } } --- 44,74 ---- public PgDbClient DB { ! get { return this.db; } } public string ConnectionString { ! get { return this.connectionString; } } public long Lifetime { ! get { return this.lifetime; } } public long Created { ! get { return this.created; } ! set { this.created = value; } } public bool Pooled { ! get { return this.pooled; } ! set { this.pooled = value; } } public PgConnectionParams Settings { ! get { return this.settings; } } *************** *** 79,89 **** private PgDbConnection() { ! settings = new PgConnectionParams(); ! search = new Regex(@"([\w\s\d]*)\s*=\s*([^;]*)"); ! connectionString = String.Empty; ! lifetime = 0; ! created = 0; ! pooled = true; } --- 79,90 ---- private PgDbConnection() { ! this.settings = new PgConnectionParams(); ! this.search = new Regex(@"([\w\s\d]*)\s*=\s*([^;]*)"); ! this.connectionString = String.Empty; ! this.lifetime = 0; ! this.created = 0; ! this.pooled = true; ! this.db = new PgDbClient(); } *************** *** 91,95 **** { this.connectionString = connectionString; ! parseConnectionString(); } --- 92,96 ---- { this.connectionString = connectionString; ! this.parseConnectionString(); } *************** *** 102,107 **** try { ! db = new PgDbClient(settings); ! db.Connect(); } catch (PgClientException ex) --- 103,108 ---- try { ! this.db.Settings = this.Settings; ! this.db.Connect(); } catch (PgClientException ex) *************** *** 115,119 **** try { ! db.Disconnect(); } catch (PgClientException ex) --- 116,120 ---- try { ! this.db.Disconnect(); } catch (PgClientException ex) *************** *** 125,129 **** private void parseConnectionString() { ! MatchCollection elements = search.Matches(connectionString); foreach (Match element in elements) --- 126,130 ---- private void parseConnectionString() { ! MatchCollection elements = search.Matches(this.connectionString); foreach (Match element in elements) *************** *** 136,184 **** case "server": case "host": ! settings.ServerName = element.Groups[2].Value.Trim(); break; case "database": ! settings.Database = element.Groups[2].Value.Trim(); break; case "user name": case "user": ! settings.UserName = element.Groups[2].Value.Trim(); break; case "user password": case "password": ! settings.UserPassword = element.Groups[2].Value.Trim(); break; case "port": ! settings.ServerPort = Int32.Parse(element.Groups[2].Value.Trim()); break; case "connection lifetime": ! lifetime = Int32.Parse(element.Groups[2].Value.Trim()); ! lifetime *= TimeSpan.TicksPerSecond; break; case "timeout": case "connection timeout": ! settings.Timeout = Int32.Parse(element.Groups[2].Value.Trim()); break; case "packet size": ! settings.PacketSize = Int32.Parse(element.Groups[2].Value.Trim()); break; case "pooling": ! settings.Pooling = Boolean.Parse(element.Groups[2].Value.Trim()); break; case "ssl": ! settings.SSL = Boolean.Parse(element.Groups[2].Value.Trim()); break; case "simple query mode": ! settings.SimpleQueryMode = Boolean.Parse(element.Groups[2].Value.Trim()); break; } --- 137,185 ---- case "server": case "host": ! this.settings.ServerName = element.Groups[2].Value.Trim(); break; case "database": ! this.settings.Database = element.Groups[2].Value.Trim(); break; case "user name": case "user": ! this.settings.UserName = element.Groups[2].Value.Trim(); break; case "user password": case "password": ! this.settings.UserPassword = element.Groups[2].Value.Trim(); break; case "port": ! this.settings.ServerPort = Int32.Parse(element.Groups[2].Value.Trim()); break; case "connection lifetime": ! this.lifetime = Int32.Parse(element.Groups[2].Value.Trim()); ! this.lifetime *= TimeSpan.TicksPerSecond; break; case "timeout": case "connection timeout": ! this.settings.Timeout = Int32.Parse(element.Groups[2].Value.Trim()); break; case "packet size": ! this.settings.PacketSize = Int32.Parse(element.Groups[2].Value.Trim()); break; case "pooling": ! this.settings.Pooling = Boolean.Parse(element.Groups[2].Value.Trim()); break; case "ssl": ! this.settings.SSL = Boolean.Parse(element.Groups[2].Value.Trim()); break; case "simple query mode": ! this.settings.SimpleQueryMode = Boolean.Parse(element.Groups[2].Value.Trim()); break; } *************** *** 203,207 **** } ! internal bool VerifyConnection() { bool isValid = true; --- 204,208 ---- } ! internal bool Verify() { bool isValid = true; |