aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-05 16:39:40 -0700
committerJohn Hurliman2009-10-05 16:39:40 -0700
commit672036937671a69426a12936c69efcb54d029e86 (patch)
tree25c322d9a2bad9f9cce2fff3569cbc0074304f33 /OpenSim/Data
parentMake sure that keys exist in arrays before trying to access them. (diff)
downloadopensim-SC-672036937671a69426a12936c69efcb54d029e86.zip
opensim-SC-672036937671a69426a12936c69efcb54d029e86.tar.gz
opensim-SC-672036937671a69426a12936c69efcb54d029e86.tar.bz2
opensim-SC-672036937671a69426a12936c69efcb54d029e86.tar.xz
Added CloseDBConnection() to replace the old CloseReaderCommand(). This will close the MySQLConnection attached to a MySQLCommand. I'm not sure if this accounts for every time a database connection needs to be closed, but it matches up 1:1 with the places where the database connection was previously being closed
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs14
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs8
4 files changed, 21 insertions, 11 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index e96a123..a41f9f8 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -82,12 +82,16 @@ namespace OpenSim.Data.MySQL
82 ret.Data[s] = result[s].ToString(); 82 ret.Data[s] = result[s].ToString();
83 } 83 }
84 84
85 CloseDBConnection(cmd);
85 return ret; 86 return ret;
86 } 87 }
88 else
89 {
90 CloseDBConnection(cmd);
91 return null;
92 }
87 } 93 }
88 } 94 }
89
90 return null;
91 } 95 }
92 96
93 public bool Store(AuthenticationData data) 97 public bool Store(AuthenticationData data)
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index c756c9c..f37e9bc 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Data.MySQL
47 protected MySqlFramework(string connectionString) 47 protected MySqlFramework(string connectionString)
48 { 48 {
49 m_Connection = new MySqlConnection(connectionString); 49 m_Connection = new MySqlConnection(connectionString);
50
51 m_Connection.Open(); 50 m_Connection.Open();
52 } 51 }
53 52
@@ -82,8 +81,7 @@ namespace OpenSim.Data.MySQL
82 errorSeen = true; 81 errorSeen = true;
83 82
84 m_Connection.Close(); 83 m_Connection.Close();
85 MySqlConnection newConnection = (MySqlConnection) 84 MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone();
86 ((ICloneable)m_Connection).Clone();
87 m_Connection.Dispose(); 85 m_Connection.Dispose();
88 m_Connection = newConnection; 86 m_Connection = newConnection;
89 m_Connection.Open(); 87 m_Connection.Open();
@@ -104,14 +102,16 @@ namespace OpenSim.Data.MySQL
104 102
105 protected IDataReader ExecuteReader(MySqlCommand cmd) 103 protected IDataReader ExecuteReader(MySqlCommand cmd)
106 { 104 {
107 MySqlConnection newConnection = (MySqlConnection) 105 MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone();
108 ((ICloneable)m_Connection).Clone();
109
110 newConnection.Open(); 106 newConnection.Open();
111 107
112 cmd.Connection = newConnection; 108 cmd.Connection = newConnection;
113
114 return cmd.ExecuteReader(); 109 return cmd.ExecuteReader();
115 } 110 }
111
112 protected void CloseDBConnection(MySqlCommand cmd)
113 {
114 cmd.Connection.Dispose();
115 }
116 } 116 }
117} 117}
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 04b24b6..3fe27d5 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL
172 172
173 retList.Add(ret); 173 retList.Add(ret);
174 } 174 }
175
176 CloseDBConnection(cmd);
175 } 177 }
176 178
177 return retList; 179 return retList;
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index c713a11..38a6f55 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -97,12 +97,16 @@ namespace OpenSim.Data.MySQL
97 ret.Data[s] = result[s].ToString(); 97 ret.Data[s] = result[s].ToString();
98 } 98 }
99 99
100 CloseDBConnection(cmd);
100 return ret; 101 return ret;
101 } 102 }
103 else
104 {
105 CloseDBConnection(cmd);
106 return null;
107 }
102 } 108 }
103 } 109 }
104
105 return null;
106 } 110 }
107 111
108 public bool Store(UserAccountData data) 112 public bool Store(UserAccountData data)