From e1b5c612472b9d1acf47383c0bf75b555daff2e6 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 4 Feb 2010 13:19:30 -0800 Subject: Updated MySQL connection management to use the MySQL connection pooling. This should accommodate various timeout problems that exist with the current connection pool code in a more general and standard way. --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 71 ++++++++++++++------------- 1 file changed, 37 insertions(+), 34 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAuthenticationData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e508b52..5056aee 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -38,16 +38,22 @@ namespace OpenSim.Data.MySQL public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData { private string m_Realm; - private List m_ColumnNames = null; - private int m_LastExpire = 0; + private List m_ColumnNames; + private int m_LastExpire; + // private string m_connectionString; public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) { m_Realm = realm; + m_connectionString = connectionString; - Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); - m.Update(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); + m.Update(); + } } public AuthenticationData Get(UUID principalID) @@ -55,45 +61,42 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - MySqlCommand cmd = new MySqlCommand( - "select * from `"+m_Realm+"` where UUID = ?principalID" - ); - - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - - IDataReader result = ExecuteReader(cmd); - - if (result.Read()) + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { - ret.PrincipalID = principalID; + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); + IDataReader result = cmd.ExecuteReader(); - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) + if (result.Read()) { - if (s == "UUID") - continue; + ret.PrincipalID = principalID; - ret.Data[s] = result[s].ToString(); - } + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); - result.Close(); - CloseReaderCommand(cmd); + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } - return ret; - } + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; - result.Close(); - CloseReaderCommand(cmd); + ret.Data[s] = result[s].ToString(); + } - return null; + return ret; + } + else + { + return null; + } + } } public bool Store(AuthenticationData data) -- cgit v1.1