diff options
author | Adam Frisby | 2008-05-26 21:53:32 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-26 21:53:32 +0000 |
commit | 77281ed85cabb7e278d179ea7ab5ca12b9a0b984 (patch) | |
tree | 8d0783b8d6445144252cd905ad3ba388fc8baac0 | |
parent | * Patch from jhurliman - Implements a binary search in the LLRAW exporter whi... (diff) | |
download | opensim-SC-77281ed85cabb7e278d179ea7ab5ca12b9a0b984.zip opensim-SC-77281ed85cabb7e278d179ea7ab5ca12b9a0b984.tar.gz opensim-SC-77281ed85cabb7e278d179ea7ab5ca12b9a0b984.tar.bz2 opensim-SC-77281ed85cabb7e278d179ea7ab5ca12b9a0b984.tar.xz |
* Potential fix for Mantis#167, 332 - MySQL Thread collision.
-rw-r--r-- | OpenSim/Data/MySQL/MySQLDataStore.cs | 137 |
1 files changed, 76 insertions, 61 deletions
diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 3c39a5e..1cd76a8 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs | |||
@@ -410,30 +410,33 @@ namespace OpenSim.Data.MySQL | |||
410 | /// <param name="prim"></param> | 410 | /// <param name="prim"></param> |
411 | private void LoadItems(SceneObjectPart prim) | 411 | private void LoadItems(SceneObjectPart prim) |
412 | { | 412 | { |
413 | //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); | 413 | lock (m_dataSet) |
414 | { | ||
415 | //m_log.InfoFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); | ||
414 | 416 | ||
415 | DataTable dbItems = m_itemsTable; | 417 | DataTable dbItems = m_itemsTable; |
416 | 418 | ||
417 | String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); | 419 | String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); |
418 | DataRow[] dbItemRows = dbItems.Select(sql); | 420 | DataRow[] dbItemRows = dbItems.Select(sql); |
419 | 421 | ||
420 | IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 422 | IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
421 | 423 | ||
422 | foreach (DataRow row in dbItemRows) | 424 | foreach (DataRow row in dbItemRows) |
423 | { | 425 | { |
424 | TaskInventoryItem item = buildItem(row); | 426 | TaskInventoryItem item = buildItem(row); |
425 | inventory.Add(item); | 427 | inventory.Add(item); |
426 | 428 | ||
427 | //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); | 429 | //m_log.DebugFormat("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID); |
428 | } | 430 | } |
429 | 431 | ||
430 | prim.RestoreInventoryItems(inventory); | 432 | prim.RestoreInventoryItems(inventory); |
431 | 433 | ||
432 | // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in | 434 | // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in |
433 | // every item). This data should really be stored in the prim table itself. | 435 | // every item). This data should really be stored in the prim table itself. |
434 | if (dbItemRows.Length > 0) | 436 | if (dbItemRows.Length > 0) |
435 | { | 437 | { |
436 | prim.FolderID = inventory[0].ParentID; | 438 | prim.FolderID = inventory[0].ParentID; |
439 | } | ||
437 | } | 440 | } |
438 | } | 441 | } |
439 | 442 | ||
@@ -442,9 +445,10 @@ namespace OpenSim.Data.MySQL | |||
442 | int revision = Util.UnixTimeSinceEpoch(); | 445 | int revision = Util.UnixTimeSinceEpoch(); |
443 | m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); | 446 | m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString()); |
444 | 447 | ||
445 | DataTable terrain = m_dataSet.Tables["terrain"]; | ||
446 | lock (m_dataSet) | 448 | lock (m_dataSet) |
447 | { | 449 | { |
450 | DataTable terrain = m_dataSet.Tables["terrain"]; | ||
451 | |||
448 | MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + | 452 | MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + |
449 | " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); | 453 | " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); |
450 | using (cmd) | 454 | using (cmd) |
@@ -921,13 +925,16 @@ namespace OpenSim.Data.MySQL | |||
921 | { | 925 | { |
922 | // Database table was created before we got here and needs to be created! :P | 926 | // Database table was created before we got here and needs to be created! :P |
923 | 927 | ||
924 | using ( | 928 | lock (m_dataSet) |
925 | MySqlCommand cmd = | ||
926 | new MySqlCommand( | ||
927 | "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", | ||
928 | m_connection)) | ||
929 | { | 929 | { |
930 | cmd.ExecuteNonQuery(); | 930 | using ( |
931 | MySqlCommand cmd = | ||
932 | new MySqlCommand( | ||
933 | "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", | ||
934 | m_connection)) | ||
935 | { | ||
936 | cmd.ExecuteNonQuery(); | ||
937 | } | ||
931 | } | 938 | } |
932 | } | 939 | } |
933 | return prim; | 940 | return prim; |
@@ -1230,14 +1237,16 @@ namespace OpenSim.Data.MySQL | |||
1230 | catch (InvalidCastException) | 1237 | catch (InvalidCastException) |
1231 | { | 1238 | { |
1232 | // Database table was created before we got here and needs to be created! :P | 1239 | // Database table was created before we got here and needs to be created! :P |
1233 | 1240 | lock (m_dataSet) | |
1234 | using ( | ||
1235 | MySqlCommand cmd = | ||
1236 | new MySqlCommand( | ||
1237 | "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", | ||
1238 | m_connection)) | ||
1239 | { | 1241 | { |
1240 | cmd.ExecuteNonQuery(); | 1242 | using ( |
1243 | MySqlCommand cmd = | ||
1244 | new MySqlCommand( | ||
1245 | "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", | ||
1246 | m_connection)) | ||
1247 | { | ||
1248 | cmd.ExecuteNonQuery(); | ||
1249 | } | ||
1241 | } | 1250 | } |
1242 | } | 1251 | } |
1243 | 1252 | ||
@@ -1283,45 +1292,51 @@ namespace OpenSim.Data.MySQL | |||
1283 | } | 1292 | } |
1284 | catch (MySqlException) | 1293 | catch (MySqlException) |
1285 | { | 1294 | { |
1286 | // Database table was created before we got here and needs to be created! :P | 1295 | lock (m_dataSet) |
1287 | using ( | ||
1288 | MySqlCommand cmd = | ||
1289 | new MySqlCommand( | ||
1290 | "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", | ||
1291 | m_connection)) | ||
1292 | { | 1296 | { |
1293 | cmd.ExecuteNonQuery(); | 1297 | // Database table was created before we got here and needs to be created! :P |
1298 | using ( | ||
1299 | MySqlCommand cmd = | ||
1300 | new MySqlCommand( | ||
1301 | "ALTER TABLE `primshapes` ADD COLUMN `State` int NOT NULL default 0;", | ||
1302 | m_connection)) | ||
1303 | { | ||
1304 | cmd.ExecuteNonQuery(); | ||
1305 | } | ||
1294 | } | 1306 | } |
1295 | } | 1307 | } |
1296 | } | 1308 | } |
1297 | 1309 | ||
1298 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) | 1310 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) |
1299 | { | 1311 | { |
1300 | DataTable prims = m_dataSet.Tables["prims"]; | 1312 | lock (m_dataSet) |
1301 | DataTable shapes = m_dataSet.Tables["primshapes"]; | ||
1302 | |||
1303 | DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); | ||
1304 | if (primRow == null) | ||
1305 | { | ||
1306 | primRow = prims.NewRow(); | ||
1307 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); | ||
1308 | prims.Rows.Add(primRow); | ||
1309 | } | ||
1310 | else | ||
1311 | { | 1313 | { |
1312 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); | 1314 | DataTable prims = m_dataSet.Tables["prims"]; |
1313 | } | 1315 | DataTable shapes = m_dataSet.Tables["primshapes"]; |
1314 | 1316 | ||
1315 | DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); | 1317 | DataRow primRow = prims.Rows.Find(Util.ToRawUuidString(prim.UUID)); |
1316 | if (shapeRow == null) | 1318 | if (primRow == null) |
1317 | { | 1319 | { |
1318 | shapeRow = shapes.NewRow(); | 1320 | primRow = prims.NewRow(); |
1319 | fillShapeRow(shapeRow, prim); | 1321 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); |
1320 | shapes.Rows.Add(shapeRow); | 1322 | prims.Rows.Add(primRow); |
1321 | } | 1323 | } |
1322 | else | 1324 | else |
1323 | { | 1325 | { |
1324 | fillShapeRow(shapeRow, prim); | 1326 | fillPrimRow(primRow, prim, sceneGroupID, regionUUID); |
1327 | } | ||
1328 | |||
1329 | DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); | ||
1330 | if (shapeRow == null) | ||
1331 | { | ||
1332 | shapeRow = shapes.NewRow(); | ||
1333 | fillShapeRow(shapeRow, prim); | ||
1334 | shapes.Rows.Add(shapeRow); | ||
1335 | } | ||
1336 | else | ||
1337 | { | ||
1338 | fillShapeRow(shapeRow, prim); | ||
1339 | } | ||
1325 | } | 1340 | } |
1326 | } | 1341 | } |
1327 | 1342 | ||