aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-26 00:08:53 +0100
committerJustin Clark-Casey (justincc)2010-08-26 00:08:53 +0100
commit8031f8ec09df4f654c86a9c7bc498664f7b9d9dc (patch)
treed6a6da4d448b9bc11ff8d1078b9be089b9872151 /OpenSim/Data
parentminor: remove mono compiler warning (diff)
downloadopensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.zip
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.gz
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.bz2
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.xz
Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs94
-rw-r--r--OpenSim/Data/MySQL/MySQLLegacyRegionData.cs210
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs9
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs9
4 files changed, 167 insertions, 155 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 7d017a6..4ce93e5 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -232,66 +232,68 @@ namespace OpenSim.Data.MSSQL
232 /// <param name="regionUUID"></param> 232 /// <param name="regionUUID"></param>
233 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 233 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
234 { 234 {
235 _Log.InfoFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); 235 lock (obj.Children)
236
237 using (SqlConnection conn = new SqlConnection(m_connectionString))
238 { 236 {
239 conn.Open(); 237 _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
240 SqlTransaction transaction = conn.BeginTransaction(); 238
241 239 using (SqlConnection conn = new SqlConnection(m_connectionString))
242 try
243 { 240 {
244 foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) 241 conn.Open();
242 SqlTransaction transaction = conn.BeginTransaction();
243
244 try
245 { 245 {
246 //Update prim 246 foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
247 using (SqlCommand sqlCommand = conn.CreateCommand())
248 {
249 sqlCommand.Transaction = transaction;
250 try
251 {
252 StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
253 }
254 catch (SqlException sqlEx)
255 {
256 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
257 throw;
258 }
259 }
260
261 //Update primshapes
262 using (SqlCommand sqlCommand = conn.CreateCommand())
263 { 247 {
264 sqlCommand.Transaction = transaction; 248 //Update prim
265 try 249 using (SqlCommand sqlCommand = conn.CreateCommand())
266 { 250 {
267 StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); 251 sqlCommand.Transaction = transaction;
252 try
253 {
254 StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
255 }
256 catch (SqlException sqlEx)
257 {
258 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
259 throw;
260 }
268 } 261 }
269 catch (SqlException sqlEx) 262
263 //Update primshapes
264 using (SqlCommand sqlCommand = conn.CreateCommand())
270 { 265 {
271 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); 266 sqlCommand.Transaction = transaction;
272 throw; 267 try
268 {
269 StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
270 }
271 catch (SqlException sqlEx)
272 {
273 _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
274 throw;
275 }
273 } 276 }
274 } 277 }
278
279 transaction.Commit();
275 } 280 }
276 281 catch (Exception ex)
277 transaction.Commit();
278 }
279 catch (Exception ex)
280 {
281 _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
282 try
283 {
284 transaction.Rollback();
285 }
286 catch (Exception ex2)
287 { 282 {
288 //Show error 283 _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
289 _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message); 284 try
290 285 {
286 transaction.Rollback();
287 }
288 catch (Exception ex2)
289 {
290 //Show error
291 _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
292
293 }
291 } 294 }
292 } 295 }
293 } 296 }
294
295 } 297 }
296 298
297 /// <summary> 299 /// <summary>
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index 1edcb5d..b756b4f 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -135,111 +135,115 @@ namespace OpenSim.Data.MySQL
135 dbcon.Open(); 135 dbcon.Open();
136 MySqlCommand cmd = dbcon.CreateCommand(); 136 MySqlCommand cmd = dbcon.CreateCommand();
137 137
138 foreach (SceneObjectPart prim in obj.Children.Values) 138 lock (obj.Children)
139 { 139 {
140 cmd.Parameters.Clear(); 140 foreach (SceneObjectPart prim in obj.Children.Values)
141 141 {
142 cmd.CommandText = "replace into prims (" + 142 cmd.Parameters.Clear();
143 "UUID, CreationDate, " + 143
144 "Name, Text, Description, " + 144 cmd.CommandText = "replace into prims (" +
145 "SitName, TouchName, ObjectFlags, " + 145 "UUID, CreationDate, " +
146 "OwnerMask, NextOwnerMask, GroupMask, " + 146 "Name, Text, Description, " +
147 "EveryoneMask, BaseMask, PositionX, " + 147 "SitName, TouchName, ObjectFlags, " +
148 "PositionY, PositionZ, GroupPositionX, " + 148 "OwnerMask, NextOwnerMask, GroupMask, " +
149 "GroupPositionY, GroupPositionZ, VelocityX, " + 149 "EveryoneMask, BaseMask, PositionX, " +
150 "VelocityY, VelocityZ, AngularVelocityX, " + 150 "PositionY, PositionZ, GroupPositionX, " +
151 "AngularVelocityY, AngularVelocityZ, " + 151 "GroupPositionY, GroupPositionZ, VelocityX, " +
152 "AccelerationX, AccelerationY, " + 152 "VelocityY, VelocityZ, AngularVelocityX, " +
153 "AccelerationZ, RotationX, " + 153 "AngularVelocityY, AngularVelocityZ, " +
154 "RotationY, RotationZ, " + 154 "AccelerationX, AccelerationY, " +
155 "RotationW, SitTargetOffsetX, " + 155 "AccelerationZ, RotationX, " +
156 "SitTargetOffsetY, SitTargetOffsetZ, " + 156 "RotationY, RotationZ, " +
157 "SitTargetOrientW, SitTargetOrientX, " + 157 "RotationW, SitTargetOffsetX, " +
158 "SitTargetOrientY, SitTargetOrientZ, " + 158 "SitTargetOffsetY, SitTargetOffsetZ, " +
159 "RegionUUID, CreatorID, " + 159 "SitTargetOrientW, SitTargetOrientX, " +
160 "OwnerID, GroupID, " + 160 "SitTargetOrientY, SitTargetOrientZ, " +
161 "LastOwnerID, SceneGroupID, " + 161 "RegionUUID, CreatorID, " +
162 "PayPrice, PayButton1, " + 162 "OwnerID, GroupID, " +
163 "PayButton2, PayButton3, " + 163 "LastOwnerID, SceneGroupID, " +
164 "PayButton4, LoopedSound, " + 164 "PayPrice, PayButton1, " +
165 "LoopedSoundGain, TextureAnimation, " + 165 "PayButton2, PayButton3, " +
166 "OmegaX, OmegaY, OmegaZ, " + 166 "PayButton4, LoopedSound, " +
167 "CameraEyeOffsetX, CameraEyeOffsetY, " + 167 "LoopedSoundGain, TextureAnimation, " +
168 "CameraEyeOffsetZ, CameraAtOffsetX, " + 168 "OmegaX, OmegaY, OmegaZ, " +
169 "CameraAtOffsetY, CameraAtOffsetZ, " + 169 "CameraEyeOffsetX, CameraEyeOffsetY, " +
170 "ForceMouselook, ScriptAccessPin, " + 170 "CameraEyeOffsetZ, CameraAtOffsetX, " +
171 "AllowedDrop, DieAtEdge, " + 171 "CameraAtOffsetY, CameraAtOffsetZ, " +
172 "SalePrice, SaleType, " + 172 "ForceMouselook, ScriptAccessPin, " +
173 "ColorR, ColorG, ColorB, ColorA, " + 173 "AllowedDrop, DieAtEdge, " +
174 "ParticleSystem, ClickAction, Material, " + 174 "SalePrice, SaleType, " +
175 "CollisionSound, CollisionSoundVolume, " + 175 "ColorR, ColorG, ColorB, ColorA, " +
176 "PassTouches, " + 176 "ParticleSystem, ClickAction, Material, " +
177 "LinkNumber, MediaURL) values (" + "?UUID, " + 177 "CollisionSound, CollisionSoundVolume, " +
178 "?CreationDate, ?Name, ?Text, " + 178 "PassTouches, " +
179 "?Description, ?SitName, ?TouchName, " + 179 "LinkNumber, MediaURL) values (" + "?UUID, " +
180 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + 180 "?CreationDate, ?Name, ?Text, " +
181 "?GroupMask, ?EveryoneMask, ?BaseMask, " + 181 "?Description, ?SitName, ?TouchName, " +
182 "?PositionX, ?PositionY, ?PositionZ, " + 182 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
183 "?GroupPositionX, ?GroupPositionY, " + 183 "?GroupMask, ?EveryoneMask, ?BaseMask, " +
184 "?GroupPositionZ, ?VelocityX, " + 184 "?PositionX, ?PositionY, ?PositionZ, " +
185 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + 185 "?GroupPositionX, ?GroupPositionY, " +
186 "?AngularVelocityY, ?AngularVelocityZ, " + 186 "?GroupPositionZ, ?VelocityX, " +
187 "?AccelerationX, ?AccelerationY, " + 187 "?VelocityY, ?VelocityZ, ?AngularVelocityX, " +
188 "?AccelerationZ, ?RotationX, " + 188 "?AngularVelocityY, ?AngularVelocityZ, " +
189 "?RotationY, ?RotationZ, " + 189 "?AccelerationX, ?AccelerationY, " +
190 "?RotationW, ?SitTargetOffsetX, " + 190 "?AccelerationZ, ?RotationX, " +
191 "?SitTargetOffsetY, ?SitTargetOffsetZ, " + 191 "?RotationY, ?RotationZ, " +
192 "?SitTargetOrientW, ?SitTargetOrientX, " + 192 "?RotationW, ?SitTargetOffsetX, " +
193 "?SitTargetOrientY, ?SitTargetOrientZ, " + 193 "?SitTargetOffsetY, ?SitTargetOffsetZ, " +
194 "?RegionUUID, ?CreatorID, ?OwnerID, " + 194 "?SitTargetOrientW, ?SitTargetOrientX, " +
195 "?GroupID, ?LastOwnerID, ?SceneGroupID, " + 195 "?SitTargetOrientY, ?SitTargetOrientZ, " +
196 "?PayPrice, ?PayButton1, ?PayButton2, " + 196 "?RegionUUID, ?CreatorID, ?OwnerID, " +
197 "?PayButton3, ?PayButton4, ?LoopedSound, " + 197 "?GroupID, ?LastOwnerID, ?SceneGroupID, " +
198 "?LoopedSoundGain, ?TextureAnimation, " + 198 "?PayPrice, ?PayButton1, ?PayButton2, " +
199 "?OmegaX, ?OmegaY, ?OmegaZ, " + 199 "?PayButton3, ?PayButton4, ?LoopedSound, " +
200 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + 200 "?LoopedSoundGain, ?TextureAnimation, " +
201 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + 201 "?OmegaX, ?OmegaY, ?OmegaZ, " +
202 "?CameraAtOffsetY, ?CameraAtOffsetZ, " + 202 "?CameraEyeOffsetX, ?CameraEyeOffsetY, " +
203 "?ForceMouselook, ?ScriptAccessPin, " + 203 "?CameraEyeOffsetZ, ?CameraAtOffsetX, " +
204 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + 204 "?CameraAtOffsetY, ?CameraAtOffsetZ, " +
205 "?SaleType, ?ColorR, ?ColorG, " + 205 "?ForceMouselook, ?ScriptAccessPin, " +
206 "?ColorB, ?ColorA, ?ParticleSystem, " + 206 "?AllowedDrop, ?DieAtEdge, ?SalePrice, " +
207 "?ClickAction, ?Material, ?CollisionSound, " + 207 "?SaleType, ?ColorR, ?ColorG, " +
208 "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; 208 "?ColorB, ?ColorA, ?ParticleSystem, " +
209 209 "?ClickAction, ?Material, ?CollisionSound, " +
210 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 210 "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)";
211 211
212 ExecuteNonQuery(cmd); 212 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
213 213
214 cmd.Parameters.Clear(); 214 ExecuteNonQuery(cmd);
215 215
216 cmd.CommandText = "replace into primshapes (" + 216 cmd.Parameters.Clear();
217 "UUID, Shape, ScaleX, ScaleY, " + 217
218 "ScaleZ, PCode, PathBegin, PathEnd, " + 218 cmd.CommandText = "replace into primshapes (" +
219 "PathScaleX, PathScaleY, PathShearX, " + 219 "UUID, Shape, ScaleX, ScaleY, " +
220 "PathShearY, PathSkew, PathCurve, " + 220 "ScaleZ, PCode, PathBegin, PathEnd, " +
221 "PathRadiusOffset, PathRevolutions, " + 221 "PathScaleX, PathScaleY, PathShearX, " +
222 "PathTaperX, PathTaperY, PathTwist, " + 222 "PathShearY, PathSkew, PathCurve, " +
223 "PathTwistBegin, ProfileBegin, ProfileEnd, " + 223 "PathRadiusOffset, PathRevolutions, " +
224 "ProfileCurve, ProfileHollow, Texture, " + 224 "PathTaperX, PathTaperY, PathTwist, " +
225 "ExtraParams, State, Media) values (?UUID, " + 225 "PathTwistBegin, ProfileBegin, ProfileEnd, " +
226 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + 226 "ProfileCurve, ProfileHollow, Texture, " +
227 "?PCode, ?PathBegin, ?PathEnd, " + 227 "ExtraParams, State, Media) values (?UUID, " +
228 "?PathScaleX, ?PathScaleY, " + 228 "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
229 "?PathShearX, ?PathShearY, " + 229 "?PCode, ?PathBegin, ?PathEnd, " +
230 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + 230 "?PathScaleX, ?PathScaleY, " +
231 "?PathRevolutions, ?PathTaperX, " + 231 "?PathShearX, ?PathShearY, " +
232 "?PathTaperY, ?PathTwist, " + 232 "?PathSkew, ?PathCurve, ?PathRadiusOffset, " +
233 "?PathTwistBegin, ?ProfileBegin, " + 233 "?PathRevolutions, ?PathTaperX, " +
234 "?ProfileEnd, ?ProfileCurve, " + 234 "?PathTaperY, ?PathTwist, " +
235 "?ProfileHollow, ?Texture, ?ExtraParams, " + 235 "?PathTwistBegin, ?ProfileBegin, " +
236 "?State, ?Media)"; 236 "?ProfileEnd, ?ProfileCurve, " +
237 237 "?ProfileHollow, ?Texture, ?ExtraParams, " +
238 FillShapeCommand(cmd, prim); 238 "?State, ?Media)";
239 239
240 ExecuteNonQuery(cmd); 240 FillShapeCommand(cmd, prim);
241
242 ExecuteNonQuery(cmd);
243 }
244
245 cmd.Dispose();
241 } 246 }
242 cmd.Dispose();
243 } 247 }
244 } 248 }
245 } 249 }
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 4208050..bfd8279 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -360,10 +360,13 @@ namespace OpenSim.Data.SQLite
360 360
361 lock (ds) 361 lock (ds)
362 { 362 {
363 foreach (SceneObjectPart prim in obj.Children.Values) 363 lock (obj.Children)
364 { 364 {
365// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); 365 foreach (SceneObjectPart prim in obj.Children.Values)
366 addPrim(prim, obj.UUID, regionUUID); 366 {
367 // m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
368 addPrim(prim, obj.UUID, regionUUID);
369 }
367 } 370 }
368 } 371 }
369 372
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
index 289fd94..779b2ed 100644
--- a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
@@ -327,10 +327,13 @@ namespace OpenSim.Data.SQLiteLegacy
327 327
328 lock (ds) 328 lock (ds)
329 { 329 {
330 foreach (SceneObjectPart prim in obj.Children.Values) 330 lock (obj.Children)
331 { 331 {
332// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); 332 foreach (SceneObjectPart prim in obj.Children.Values)
333 addPrim(prim, obj.UUID, regionUUID); 333 {
334 // m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
335 addPrim(prim, obj.UUID, regionUUID);
336 }
334 } 337 }
335 } 338 }
336 339