aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorTedd Hansen2008-02-05 12:18:50 +0000
committerTedd Hansen2008-02-05 12:18:50 +0000
commit1d95f0521d098f514e4331a2c43c5c212df879be (patch)
treeed9bc2c7316e5a5b490b5c52e57937cf6890d371 /OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
parent* Refactored the sound calls to SceneObjectPart (diff)
downloadopensim-SC-1d95f0521d098f514e4331a2c43c5c212df879be.zip
opensim-SC-1d95f0521d098f514e4331a2c43c5c212df879be.tar.gz
opensim-SC-1d95f0521d098f514e4331a2c43c5c212df879be.tar.bz2
opensim-SC-1d95f0521d098f514e4331a2c43c5c212df879be.tar.xz
Reverted MySQLDataStore.cs to not use static mutexes any more, patch didn't work anyway.
Added js to OpenSim.ini.example.
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLDataStore.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLDataStore.cs61
1 files changed, 24 insertions, 37 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
index b25924c..54f39bb 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
@@ -50,7 +50,6 @@ namespace OpenSim.Framework.Data.MySQL
50 private const string m_landAccessListSelect = "select * from landaccesslist"; 50 private const string m_landAccessListSelect = "select * from landaccesslist";
51 51
52 private DataSet m_dataSet; 52 private DataSet m_dataSet;
53 private static object DBAccessLock = new object(); // Trying to use a static object because there might be other regions that keep modifying table
54 private MySqlDataAdapter m_primDataAdapter; 53 private MySqlDataAdapter m_primDataAdapter;
55 private MySqlDataAdapter m_shapeDataAdapter; 54 private MySqlDataAdapter m_shapeDataAdapter;
56 private MySqlDataAdapter m_itemsDataAdapter; 55 private MySqlDataAdapter m_itemsDataAdapter;
@@ -104,7 +103,7 @@ namespace OpenSim.Framework.Data.MySQL
104 103
105 TestTables(m_connection); 104 TestTables(m_connection);
106 105
107 lock (DBAccessLock) 106 lock (m_dataSet)
108 { 107 {
109 m_primTable = createPrimTable(); 108 m_primTable = createPrimTable();
110 m_dataSet.Tables.Add(m_primTable); 109 m_dataSet.Tables.Add(m_primTable);
@@ -143,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL
143 142
144 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) 143 public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID)
145 { 144 {
146 lock (DBAccessLock) 145 lock (m_dataSet)
147 { 146 {
148 foreach (SceneObjectPart prim in obj.Children.Values) 147 foreach (SceneObjectPart prim in obj.Children.Values)
149 { 148 {
@@ -170,7 +169,7 @@ namespace OpenSim.Framework.Data.MySQL
170 DataTable shapes = m_shapeTable; 169 DataTable shapes = m_shapeTable;
171 170
172 string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'"; 171 string selectExp = "SceneGroupID = '" + Util.ToRawUuidString(obj) + "'";
173 lock (DBAccessLock) 172 lock (m_dataSet)
174 { 173 {
175 DataRow[] primRows = prims.Select(selectExp); 174 DataRow[] primRows = prims.Select(selectExp);
176 foreach (DataRow row in primRows) 175 foreach (DataRow row in primRows)
@@ -226,7 +225,7 @@ namespace OpenSim.Framework.Data.MySQL
226 string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; 225 string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'";
227 string orderByParent = "ParentID ASC"; 226 string orderByParent = "ParentID ASC";
228 227
229 lock (DBAccessLock) 228 lock (m_dataSet)
230 { 229 {
231 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); 230 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
232 MainLog.Instance.Verbose("DATASTORE", 231 MainLog.Instance.Verbose("DATASTORE",
@@ -336,7 +335,7 @@ namespace OpenSim.Framework.Data.MySQL
336 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); 335 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
337 336
338 DataTable terrain = m_dataSet.Tables["terrain"]; 337 DataTable terrain = m_dataSet.Tables["terrain"];
339 lock (DBAccessLock) 338 lock (m_dataSet)
340 { 339 {
341 MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + 340 MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" +
342 " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); 341 " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection);
@@ -397,7 +396,7 @@ namespace OpenSim.Framework.Data.MySQL
397 396
398 public void RemoveLandObject(LLUUID globalID) 397 public void RemoveLandObject(LLUUID globalID)
399 { 398 {
400 lock (DBAccessLock) 399 lock (m_dataSet)
401 { 400 {
402 using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection)) 401 using (MySqlCommand cmd = new MySqlCommand("delete from land where UUID=?UUID", m_connection))
403 { 402 {
@@ -422,7 +421,7 @@ namespace OpenSim.Framework.Data.MySQL
422 MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); 421 MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))");
423 System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900)); 422 System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900));
424 423
425 lock (DBAccessLock) 424 lock (m_dataSet)
426 { 425 {
427 DataTable land = m_landTable; 426 DataTable land = m_landTable;
428 DataTable landaccesslist = m_landAccessListTable; 427 DataTable landaccesslist = m_landAccessListTable;
@@ -454,14 +453,14 @@ namespace OpenSim.Framework.Data.MySQL
454 landaccesslist.Rows.Add(newAccessRow); 453 landaccesslist.Rows.Add(newAccessRow);
455 } 454 }
456 455
457 Commit_NoLock();
458 } 456 }
457 Commit();
459 } 458 }
460 459
461 public List<LandData> LoadLandObjects(LLUUID regionUUID) 460 public List<LandData> LoadLandObjects(LLUUID regionUUID)
462 { 461 {
463 List<LandData> landDataForRegion = new List<LandData>(); 462 List<LandData> landDataForRegion = new List<LandData>();
464 lock (DBAccessLock) 463 lock (m_dataSet)
465 { 464 {
466 DataTable land = m_landTable; 465 DataTable land = m_landTable;
467 DataTable landaccesslist = m_landAccessListTable; 466 DataTable landaccesslist = m_landAccessListTable;
@@ -523,39 +522,27 @@ namespace OpenSim.Framework.Data.MySQL
523 m_connection.Open(); 522 m_connection.Open();
524 } 523 }
525 524
526 lock (DBAccessLock) 525 lock (m_dataSet)
527 { 526 {
528 // Moved code to own sub that can be called directly by "StoreLandObject". 527 // DisplayDataSet(m_dataSet, "Region DataSet");
529 // Problem is that:
530 // - StoreLandObject locks
531 // - Some other function waits for lock
532 // - StoreLandObject releases lock
533 // - Other function obtains lock
534 // - StoreLandObject calls Commit that tries to take lock back
535 // - When StoreLandObject's Commit finally gets lock the table has been changed and we crash
536 Commit_NoLock();
537 }
538 }
539 528
540 private void Commit_NoLock() 529 m_primDataAdapter.Update(m_primTable);
541 { 530 m_shapeDataAdapter.Update(m_shapeTable);
542 // DisplayDataSet(m_dataSet, "Region DataSet");
543 531
544 m_primDataAdapter.Update(m_primTable); 532 if (persistPrimInventories)
545 m_shapeDataAdapter.Update(m_shapeTable); 533 {
546 534 m_itemsDataAdapter.Update(m_itemsTable);
547 if (persistPrimInventories) 535 }
548 {
549 m_itemsDataAdapter.Update(m_itemsTable);
550 }
551 536
552 m_terrainDataAdapter.Update(m_terrainTable); 537 m_terrainDataAdapter.Update(m_terrainTable);
553 m_landDataAdapter.Update(m_landTable); 538 m_landDataAdapter.Update(m_landTable);
554 m_landAccessListDataAdapter.Update(m_landAccessListTable); 539 m_landAccessListDataAdapter.Update(m_landAccessListTable);
555 540
556 m_dataSet.AcceptChanges(); 541 m_dataSet.AcceptChanges();
542 }
557 } 543 }
558 544
545
559 public void Shutdown() 546 public void Shutdown()
560 { 547 {
561 Commit(); 548 Commit();
@@ -1231,7 +1218,7 @@ namespace OpenSim.Framework.Data.MySQL
1231 1218
1232 // For now, we're just going to crudely remove all the previous inventory items 1219 // For now, we're just going to crudely remove all the previous inventory items
1233 // no matter whether they have changed or not, and replace them with the current set. 1220 // no matter whether they have changed or not, and replace them with the current set.
1234 lock (DBAccessLock) 1221 lock (m_dataSet)
1235 { 1222 {
1236 RemoveItems(primID); 1223 RemoveItems(primID);
1237 1224