aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2014-09-12 11:48:43 +0100
committerUbitUmarov2014-09-12 11:48:43 +0100
commitffe5ede55086e8e680b770481604defd4125b398 (patch)
tree90520b8cb0fe4160c75400c25f9ca2054dbdef41 /OpenSim/Region/Framework/Scenes
parent handle AO sit ground case (diff)
downloadopensim-SC-ffe5ede55086e8e680b770481604defd4125b398.zip
opensim-SC-ffe5ede55086e8e680b770481604defd4125b398.tar.gz
opensim-SC-ffe5ede55086e8e680b770481604defd4125b398.tar.bz2
opensim-SC-ffe5ede55086e8e680b770481604defd4125b398.tar.xz
taskInventory request: give each transfer a diferent filename, Add more
agressive lock
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs197
1 files changed, 96 insertions, 101 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a6a963b..7328a39 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -46,10 +46,10 @@ namespace OpenSim.Region.Framework.Scenes
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private string m_inventoryFileName = String.Empty;
50 private byte[] m_inventoryFileData = new byte[0]; 49 private byte[] m_inventoryFileData = new byte[0];
51 private uint m_inventoryFileNameSerial = 0; 50 private uint m_inventoryFileNameSerial = 0;
52 private bool m_inventoryPrivileged = false; 51 private bool m_inventoryPrivileged = false;
52 private object m_inventoryFileLock = new object();
53 53
54 private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); 54 private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
55 55
@@ -1110,23 +1110,6 @@ namespace OpenSim.Region.Framework.Scenes
1110 return -1; 1110 return -1;
1111 } 1111 }
1112 1112
1113 private bool CreateInventoryFileName()
1114 {
1115// m_log.DebugFormat(
1116// "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}",
1117// m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial);
1118
1119 if (m_inventoryFileName == String.Empty ||
1120 m_inventoryFileNameSerial < m_inventorySerial)
1121 {
1122 m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
1123 m_inventoryFileNameSerial = m_inventorySerial;
1124
1125 return true;
1126 }
1127
1128 return false;
1129 }
1130 1113
1131 /// <summary> 1114 /// <summary>
1132 /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client 1115 /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
@@ -1134,110 +1117,122 @@ namespace OpenSim.Region.Framework.Scenes
1134 /// <param name="xferManager"></param> 1117 /// <param name="xferManager"></param>
1135 public void RequestInventoryFile(IClientAPI client, IXfer xferManager) 1118 public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
1136 { 1119 {
1137 bool changed = CreateInventoryFileName();
1138
1139 bool includeAssets = false;
1140 if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
1141 includeAssets = true;
1142
1143 if (m_inventoryPrivileged != includeAssets)
1144 changed = true;
1145
1146 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
1147 1120
1148 Items.LockItemsForRead(true); 1121 lock (m_inventoryFileLock)
1149
1150 if (m_inventorySerial == 0) // No inventory
1151 { 1122 {
1152 client.SendTaskInventory(m_part.UUID, 0, new byte[0]); 1123 string filename = "inventory_" + UUID.Random().ToString() + ".tmp";
1153 Items.LockItemsForRead(false);
1154 return;
1155 }
1156 1124
1157 if (m_items.Count == 0) // No inventory 1125 bool changed = false;
1158 { 1126 if (m_inventoryFileNameSerial < m_inventorySerial)
1159 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1160 Items.LockItemsForRead(false);
1161 return;
1162 }
1163
1164 if (!changed)
1165 {
1166 if (m_inventoryFileData.Length > 2)
1167 { 1127 {
1168 xferManager.AddNewFile(m_inventoryFileName, 1128 m_inventoryFileNameSerial = m_inventorySerial;
1169 m_inventoryFileData); 1129 changed = true;
1170 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
1171 Util.StringToBytes256(m_inventoryFileName));
1172
1173 Items.LockItemsForRead(false);
1174 return;
1175 } 1130 }
1176 }
1177 1131
1178 m_inventoryPrivileged = includeAssets; 1132 if (m_inventoryFileData.Length < 2)
1133 changed = true;
1179 1134
1180 foreach (TaskInventoryItem item in m_items.Values) 1135 bool includeAssets = false;
1181 { 1136 if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
1182 UUID ownerID = item.OwnerID; 1137 includeAssets = true;
1183 uint everyoneMask = 0;
1184 uint baseMask = item.BasePermissions;
1185 uint ownerMask = item.CurrentPermissions;
1186 uint groupMask = item.GroupPermissions;
1187 1138
1188 invString.AddItemStart(); 1139 if (m_inventoryPrivileged != includeAssets)
1189 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 1140 changed = true;
1190 invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
1191 1141
1192 invString.AddPermissionsStart();
1193 1142
1194 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); 1143 Items.LockItemsForRead(true);
1195 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
1196 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
1197 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
1198 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
1199 1144
1200 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 1145 if (m_inventorySerial == 0) // No inventory
1201 invString.AddNameValueLine("owner_id", ownerID.ToString()); 1146 {
1147 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1148 Items.LockItemsForRead(false);
1149 return;
1150 }
1202 1151
1203 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 1152 if (m_items.Count == 0) // No inventory
1153 {
1154 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1155 Items.LockItemsForRead(false);
1156 return;
1157 }
1204 1158
1205 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 1159 if (!changed)
1206 invString.AddSectionEnd(); 1160 {
1161 xferManager.AddNewFile(filename,
1162 m_inventoryFileData);
1163 client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
1164 Util.StringToBytes256(filename));
1207 1165
1208 if (includeAssets) 1166 Items.LockItemsForRead(false);
1209 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 1167 return;
1210 else 1168 }
1211 invString.AddNameValueLine("asset_id", UUID.Zero.ToString());
1212 invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type));
1213 invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType));
1214 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
1215 1169
1216 invString.AddSaleStart(); 1170 m_inventoryPrivileged = includeAssets;
1217 invString.AddNameValueLine("sale_type", "not");
1218 invString.AddNameValueLine("sale_price", "0");
1219 invString.AddSectionEnd();
1220 1171
1221 invString.AddNameValueLine("name", item.Name + "|"); 1172 InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
1222 invString.AddNameValueLine("desc", item.Description + "|");
1223 1173
1224 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 1174 foreach (TaskInventoryItem item in m_items.Values)
1225 invString.AddSectionEnd(); 1175 {
1226 } 1176 UUID ownerID = item.OwnerID;
1177 uint everyoneMask = 0;
1178 uint baseMask = item.BasePermissions;
1179 uint ownerMask = item.CurrentPermissions;
1180 uint groupMask = item.GroupPermissions;
1181
1182 invString.AddItemStart();
1183 invString.AddNameValueLine("item_id", item.ItemID.ToString());
1184 invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
1185
1186 invString.AddPermissionsStart();
1187
1188 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
1189 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
1190 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
1191 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
1192 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
1193
1194 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
1195 invString.AddNameValueLine("owner_id", ownerID.ToString());
1196
1197 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
1198
1199 invString.AddNameValueLine("group_id", item.GroupID.ToString());
1200 invString.AddSectionEnd();
1201
1202 if (includeAssets)
1203 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
1204 else
1205 invString.AddNameValueLine("asset_id", UUID.Zero.ToString());
1206 invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type));
1207 invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType));
1208 invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
1209
1210 invString.AddSaleStart();
1211 invString.AddNameValueLine("sale_type", "not");
1212 invString.AddNameValueLine("sale_price", "0");
1213 invString.AddSectionEnd();
1214
1215 invString.AddNameValueLine("name", item.Name + "|");
1216 invString.AddNameValueLine("desc", item.Description + "|");
1217
1218 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
1219 invString.AddSectionEnd();
1220 }
1227 1221
1228 Items.LockItemsForRead(false); 1222 Items.LockItemsForRead(false);
1229 1223
1230 m_inventoryFileData = Utils.StringToBytes(invString.BuildString); 1224 m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
1231 1225
1232 if (m_inventoryFileData.Length > 2) 1226 if (m_inventoryFileData.Length > 2)
1233 { 1227 {
1234 xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); 1228 xferManager.AddNewFile(filename, m_inventoryFileData);
1235 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, 1229 client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
1236 Util.StringToBytes256(m_inventoryFileName)); 1230 Util.StringToBytes256(filename));
1237 return; 1231 return;
1238 } 1232 }
1239 1233
1240 client.SendTaskInventory(m_part.UUID, 0, new byte[0]); 1234 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1235 }
1241 } 1236 }
1242 1237
1243 /// <summary> 1238 /// <summary>