aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-21 15:12:00 +0000
committerJustin Clarke Casey2008-01-21 15:12:00 +0000
commit7ca8e28a9a518e5ff646676713a7be46ba172ca3 (patch)
tree99bd4b5977b54a2120591629d7e47cb9d5ed7406 /OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs
parent* Make object persistence more granular by separating prim and prim inventory... (diff)
downloadopensim-SC_OLD-7ca8e28a9a518e5ff646676713a7be46ba172ca3.zip
opensim-SC_OLD-7ca8e28a9a518e5ff646676713a7be46ba172ca3.tar.gz
opensim-SC_OLD-7ca8e28a9a518e5ff646676713a7be46ba172ca3.tar.bz2
opensim-SC_OLD-7ca8e28a9a518e5ff646676713a7be46ba172ca3.tar.xz
Properly lock new separate database accesses
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs107
1 files changed, 55 insertions, 52 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs
index 76848cf..ba50dca 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs
@@ -1258,63 +1258,66 @@ namespace OpenSim.Framework.Data.SQLite
1258 1258
1259 MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID); 1259 MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID);
1260 1260
1261 // Find all existing inventory rows for this prim 1261 lock (ds)
1262 DataTable dbItems = ds.Tables["primitems"];
1263
1264 String sql = String.Format("primID = '{0}'", primID);
1265 DataRow[] dbItemRows = dbItems.Select(sql);
1266
1267 // Build structures for manipulation purposes
1268 IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
1269 ICollection<TaskInventoryItem> itemsToAdd
1270 = new List<TaskInventoryItem>();
1271
1272 foreach (DataRow row in dbItemRows)
1273 {
1274 dbItemsToRemove.Add((String)row["itemID"], row);
1275 }
1276
1277 // Eliminate rows from the deletion set which already exist for this prim's inventory
1278 // TODO Very temporary, need to take account of simple metadata changes soon
1279 lock (items)
1280 { 1262 {
1281 foreach (LLUUID itemId in items.Keys) 1263 // Find all existing inventory rows for this prim
1264 DataTable dbItems = ds.Tables["primitems"];
1265
1266 String sql = String.Format("primID = '{0}'", primID);
1267 DataRow[] dbItemRows = dbItems.Select(sql);
1268
1269 // Build structures for manipulation purposes
1270 IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
1271 ICollection<TaskInventoryItem> itemsToAdd
1272 = new List<TaskInventoryItem>();
1273
1274 foreach (DataRow row in dbItemRows)
1282 { 1275 {
1283 String rawItemId = itemId.ToString(); 1276 dbItemsToRemove.Add((String)row["itemID"], row);
1284 1277 }
1285 if (dbItemsToRemove.ContainsKey(rawItemId)) 1278
1286 { 1279 // Eliminate rows from the deletion set which already exist for this prim's inventory
1287 dbItemsToRemove.Remove(rawItemId); 1280 // TODO Very temporary, need to take account of simple metadata changes soon
1288 } 1281 lock (items)
1289 else 1282 {
1283 foreach (LLUUID itemId in items.Keys)
1290 { 1284 {
1291 itemsToAdd.Add(items[itemId]); 1285 String rawItemId = itemId.ToString();
1292 } 1286
1293 } 1287 if (dbItemsToRemove.ContainsKey(rawItemId))
1294 } 1288 {
1295 1289 dbItemsToRemove.Remove(rawItemId);
1296 // Delete excess rows 1290 }
1297 foreach (DataRow row in dbItemsToRemove.Values) 1291 else
1298 { 1292 {
1299 MainLog.Instance.Verbose( 1293 itemsToAdd.Add(items[itemId]);
1300 "DATASTORE", 1294 }
1301 "Removing item {0}, {1} from prim ID {2}", 1295 }
1302 row["name"], row["itemID"], row["primID"]); 1296 }
1303 1297
1304 row.Delete(); 1298 // Delete excess rows
1305 } 1299 foreach (DataRow row in dbItemsToRemove.Values)
1306 1300 {
1307 // Insert items not already present 1301 MainLog.Instance.Verbose(
1308 foreach (TaskInventoryItem newItem in itemsToAdd) 1302 "DATASTORE",
1309 { 1303 "Removing item {0}, {1} from prim ID {2}",
1310 MainLog.Instance.Verbose( 1304 row["name"], row["itemID"], row["primID"]);
1311 "DATASTORE", 1305
1312 "Adding item {0}, {1} to prim ID {2}", 1306 row.Delete();
1313 newItem.Name, newItem.ItemID, newItem.ParentPartID); 1307 }
1314 1308
1315 DataRow newItemRow = dbItems.NewRow(); 1309 // Insert items not already present
1316 fillItemRow(newItemRow, newItem); 1310 foreach (TaskInventoryItem newItem in itemsToAdd)
1317 dbItems.Rows.Add(newItemRow); 1311 {
1312 MainLog.Instance.Verbose(
1313 "DATASTORE",
1314 "Adding item {0}, {1} to prim ID {2}",
1315 newItem.Name, newItem.ItemID, newItem.ParentPartID);
1316
1317 DataRow newItemRow = dbItems.NewRow();
1318 fillItemRow(newItemRow, newItem);
1319 dbItems.Rows.Add(newItemRow);
1320 }
1318 } 1321 }
1319 } 1322 }
1320 1323