aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
authorDiva Canto2009-10-04 14:06:28 -0700
committerDiva Canto2009-10-04 14:06:28 -0700
commit08d3650138c106529dedd4659472868097e85ecc (patch)
tree7b63f4a8bdb03e1654abb8bf0f449d0fe39ad78a /OpenSim/Data/MySQL/MySQLAssetData.cs
parentReduced locking. (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-08d3650138c106529dedd4659472868097e85ecc.zip
opensim-SC_OLD-08d3650138c106529dedd4659472868097e85ecc.tar.gz
opensim-SC_OLD-08d3650138c106529dedd4659472868097e85ecc.tar.bz2
opensim-SC_OLD-08d3650138c106529dedd4659472868097e85ecc.tar.xz
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs102
1 files changed, 48 insertions, 54 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 0502b2b..8f97440 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -142,46 +142,45 @@ namespace OpenSim.Data.MySQL
142 { 142 {
143 _dbConnection.CheckConnection(); 143 _dbConnection.CheckConnection();
144 144
145 MySqlCommand cmd = 145 using (MySqlCommand cmd = new MySqlCommand(
146 new MySqlCommand( 146 "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
147 "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", 147 _dbConnection.Connection))
148 _dbConnection.Connection);
149 cmd.Parameters.AddWithValue("?id", assetID.ToString());
150
151 try
152 { 148 {
153 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 149 cmd.Parameters.AddWithValue("?id", assetID.ToString());
150
151 try
154 { 152 {
155 if (dbReader.Read()) 153 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
156 { 154 {
157 asset = new AssetBase(); 155 if (dbReader.Read())
158 asset.Data = (byte[]) dbReader["data"];
159 asset.Description = (string) dbReader["description"];
160 asset.FullID = assetID;
161 try
162 {
163 asset.Local = (bool)dbReader["local"];
164 }
165 catch (InvalidCastException)
166 { 156 {
167 asset.Local = false; 157 asset = new AssetBase();
158 asset.Data = (byte[])dbReader["data"];
159 asset.Description = (string)dbReader["description"];
160 asset.FullID = assetID;
161
162 string local = dbReader["local"].ToString();
163 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
164 asset.Local = true;
165 else
166 asset.Local = false;
167
168 asset.Name = (string)dbReader["name"];
169 asset.Type = (sbyte)dbReader["assetType"];
170 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
168 } 171 }
169 asset.Name = (string) dbReader["name"];
170 asset.Type = (sbyte) dbReader["assetType"];
171 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
172 } 172 }
173 dbReader.Close(); 173
174 cmd.Dispose(); 174 if (asset != null)
175 UpdateAccessTime(asset);
176 }
177 catch (Exception e)
178 {
179 m_log.ErrorFormat(
180 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
181 + Environment.NewLine + "Reconnecting", assetID);
182 _dbConnection.Reconnect();
175 } 183 }
176 if (asset != null)
177 UpdateAccessTime(asset);
178 }
179 catch (Exception e)
180 {
181 m_log.ErrorFormat(
182 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
183 + Environment.NewLine + "Reconnecting", assetID);
184 _dbConnection.Reconnect();
185 } 184 }
186 } 185 }
187 return asset; 186 return asset;
@@ -297,32 +296,27 @@ namespace OpenSim.Data.MySQL
297 { 296 {
298 _dbConnection.CheckConnection(); 297 _dbConnection.CheckConnection();
299 298
300 MySqlCommand cmd = 299 using (MySqlCommand cmd = new MySqlCommand(
301 new MySqlCommand( 300 "SELECT id FROM assets WHERE id=?id",
302 "SELECT id FROM assets WHERE id=?id", 301 _dbConnection.Connection))
303 _dbConnection.Connection);
304
305 cmd.Parameters.AddWithValue("?id", uuid.ToString());
306
307 try
308 { 302 {
309 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 303 cmd.Parameters.AddWithValue("?id", uuid.ToString());
304
305 try
310 { 306 {
311 if (dbReader.Read()) 307 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
312 { 308 {
313 assetExists = true; 309 if (dbReader.Read())
310 assetExists = true;
314 } 311 }
315
316 dbReader.Close();
317 cmd.Dispose();
318 } 312 }
319 } 313 catch (Exception e)
320 catch (Exception e) 314 {
321 { 315 m_log.ErrorFormat(
322 m_log.ErrorFormat( 316 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
323 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() 317 + Environment.NewLine + "Attempting reconnection", uuid);
324 + Environment.NewLine + "Attempting reconnection", uuid); 318 _dbConnection.Reconnect();
325 _dbConnection.Reconnect(); 319 }
326 } 320 }
327 } 321 }
328 322