diff options
author | Master ScienceSim | 2010-02-04 13:19:30 -0800 |
---|---|---|
committer | John Hurliman | 2010-02-05 18:07:59 -0800 |
commit | e1b5c612472b9d1acf47383c0bf75b555daff2e6 (patch) | |
tree | 083896698038fbdad59c2bd3adeba9b290c5ce1b /OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |
parent | Fixing an incorrect logging message in insertUserRow (diff) | |
download | opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.zip opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.gz opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.bz2 opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.xz |
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.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAuthenticationData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 71 |
1 files changed, 37 insertions, 34 deletions
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 | |||
38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData | 38 | public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData |
39 | { | 39 | { |
40 | private string m_Realm; | 40 | private string m_Realm; |
41 | private List<string> m_ColumnNames = null; | 41 | private List<string> m_ColumnNames; |
42 | private int m_LastExpire = 0; | 42 | private int m_LastExpire; |
43 | // private string m_connectionString; | ||
43 | 44 | ||
44 | public MySqlAuthenticationData(string connectionString, string realm) | 45 | public MySqlAuthenticationData(string connectionString, string realm) |
45 | : base(connectionString) | 46 | : base(connectionString) |
46 | { | 47 | { |
47 | m_Realm = realm; | 48 | m_Realm = realm; |
49 | m_connectionString = connectionString; | ||
48 | 50 | ||
49 | Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore"); | 51 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
50 | m.Update(); | 52 | { |
53 | dbcon.Open(); | ||
54 | Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); | ||
55 | m.Update(); | ||
56 | } | ||
51 | } | 57 | } |
52 | 58 | ||
53 | public AuthenticationData Get(UUID principalID) | 59 | public AuthenticationData Get(UUID principalID) |
@@ -55,45 +61,42 @@ namespace OpenSim.Data.MySQL | |||
55 | AuthenticationData ret = new AuthenticationData(); | 61 | AuthenticationData ret = new AuthenticationData(); |
56 | ret.Data = new Dictionary<string, object>(); | 62 | ret.Data = new Dictionary<string, object>(); |
57 | 63 | ||
58 | MySqlCommand cmd = new MySqlCommand( | 64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
59 | "select * from `"+m_Realm+"` where UUID = ?principalID" | ||
60 | ); | ||
61 | |||
62 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
63 | |||
64 | IDataReader result = ExecuteReader(cmd); | ||
65 | |||
66 | if (result.Read()) | ||
67 | { | 65 | { |
68 | ret.PrincipalID = principalID; | 66 | dbcon.Open(); |
67 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); | ||
68 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
69 | 69 | ||
70 | if (m_ColumnNames == null) | 70 | IDataReader result = cmd.ExecuteReader(); |
71 | { | ||
72 | m_ColumnNames = new List<string>(); | ||
73 | 71 | ||
74 | DataTable schemaTable = result.GetSchemaTable(); | 72 | if (result.Read()) |
75 | foreach (DataRow row in schemaTable.Rows) | ||
76 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
77 | } | ||
78 | |||
79 | foreach (string s in m_ColumnNames) | ||
80 | { | 73 | { |
81 | if (s == "UUID") | 74 | ret.PrincipalID = principalID; |
82 | continue; | ||
83 | 75 | ||
84 | ret.Data[s] = result[s].ToString(); | 76 | if (m_ColumnNames == null) |
85 | } | 77 | { |
78 | m_ColumnNames = new List<string>(); | ||
86 | 79 | ||
87 | result.Close(); | 80 | DataTable schemaTable = result.GetSchemaTable(); |
88 | CloseReaderCommand(cmd); | 81 | foreach (DataRow row in schemaTable.Rows) |
82 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
83 | } | ||
89 | 84 | ||
90 | return ret; | 85 | foreach (string s in m_ColumnNames) |
91 | } | 86 | { |
87 | if (s == "UUID") | ||
88 | continue; | ||
92 | 89 | ||
93 | result.Close(); | 90 | ret.Data[s] = result[s].ToString(); |
94 | CloseReaderCommand(cmd); | 91 | } |
95 | 92 | ||
96 | return null; | 93 | return ret; |
94 | } | ||
95 | else | ||
96 | { | ||
97 | return null; | ||
98 | } | ||
99 | } | ||
97 | } | 100 | } |
98 | 101 | ||
99 | public bool Store(AuthenticationData data) | 102 | public bool Store(AuthenticationData data) |