aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.MySQL')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLAssetData.cs66
1 files changed, 35 insertions, 31 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
index 567412f..407d6d2 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
@@ -76,6 +76,7 @@ namespace OpenSim.Framework.Data.MySQL
76 _dbConnection.Connection); 76 _dbConnection.Connection);
77 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 77 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
78 p.Value = assetID.GetBytes(); 78 p.Value = assetID.GetBytes();
79
79 try 80 try
80 { 81 {
81 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 82 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -107,39 +108,42 @@ namespace OpenSim.Framework.Data.MySQL
107 } 108 }
108 109
109 public void CreateAsset(AssetBase asset) 110 public void CreateAsset(AssetBase asset)
110 { 111 {
111 MySqlCommand cmd = 112 lock (_dbConnection)
112 new MySqlCommand( 113 {
113 "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + 114 MySqlCommand cmd =
114 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", 115 new MySqlCommand(
115 _dbConnection.Connection); 116 "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
116 117 "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
117 // need to ensure we dispose 118 _dbConnection.Connection);
118 try 119
119 { 120 // need to ensure we dispose
120 using (cmd) 121 try
121 { 122 {
122 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); 123 using (cmd)
123 p.Value = asset.FullID.GetBytes(); 124 {
124 cmd.Parameters.AddWithValue("?name", asset.Name); 125 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
125 cmd.Parameters.AddWithValue("?description", asset.Description); 126 p.Value = asset.FullID.GetBytes();
126 cmd.Parameters.AddWithValue("?assetType", asset.Type); 127 cmd.Parameters.AddWithValue("?name", asset.Name);
127 cmd.Parameters.AddWithValue("?invType", asset.InvType); 128 cmd.Parameters.AddWithValue("?description", asset.Description);
128 cmd.Parameters.AddWithValue("?local", asset.Local); 129 cmd.Parameters.AddWithValue("?assetType", asset.Type);
129 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 130 cmd.Parameters.AddWithValue("?invType", asset.InvType);
130 cmd.Parameters.AddWithValue("?data", asset.Data); 131 cmd.Parameters.AddWithValue("?local", asset.Local);
131 cmd.ExecuteNonQuery(); 132 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
132 cmd.Dispose(); 133 cmd.Parameters.AddWithValue("?data", asset.Data);
134 cmd.ExecuteNonQuery();
135 cmd.Dispose();
136 }
133 } 137 }
138 catch (Exception e)
139 {
140 MainLog.Instance.Error(
141 "ASSETS",
142 "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString()
143 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
144 _dbConnection.Reconnect();
145 }
134 } 146 }
135 catch (Exception e)
136 {
137 MainLog.Instance.Error(
138 "ASSETS",
139 "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString()
140 + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
141 _dbConnection.Reconnect();
142 }
143 } 147 }
144 148
145 public void UpdateAsset(AssetBase asset) 149 public void UpdateAsset(AssetBase asset)