diff options
Diffstat (limited to 'OpenSim')
11 files changed, 339 insertions, 328 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index e3a9a22..2fb1c63 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | 31 | using System.Linq; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | ||
33 | using log4net; | 34 | using log4net; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -59,7 +60,6 @@ namespace OpenSim.Capabilities.Handlers | |||
59 | m_LibraryService = libService; | 60 | m_LibraryService = libService; |
60 | m_Scene = s; | 61 | m_Scene = s; |
61 | } | 62 | } |
62 | |||
63 | 63 | ||
64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
65 | { | 65 | { |
@@ -93,8 +93,8 @@ namespace OpenSim.Capabilities.Handlers | |||
93 | 93 | ||
94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | 94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; |
95 | 95 | ||
96 | string response = ""; | 96 | StringBuilder tmpresponse = new StringBuilder(1024); |
97 | string bad_folders_response = ""; | 97 | StringBuilder tmpbadfolders = new StringBuilder(1024); |
98 | 98 | ||
99 | List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); | 99 | List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); |
100 | for (int i = 0; i < foldersrequested.Count; i++) | 100 | for (int i = 0; i < foldersrequested.Count; i++) |
@@ -136,49 +136,44 @@ namespace OpenSim.Capabilities.Handlers | |||
136 | string inventoryitemstr = string.Empty; | 136 | string inventoryitemstr = string.Empty; |
137 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) | 137 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) |
138 | { | 138 | { |
139 | LLSDInventoryDescendents reply = ToLLSD(icoll.Collection, icoll.Descendents); | 139 | LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents); |
140 | 140 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(thiscontents); | |
141 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | 141 | // inventoryitemstr = inventoryitemstr.Replace("<llsd>", ""); |
142 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | 142 | // inventoryitemstr = inventoryitemstr.Replace("</llsd>", ""); |
143 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | 143 | // inventoryitemstr = inventoryitemstr.Substring(6,inventoryitemstr.Length - 13); |
144 | 144 | // tmpresponse.Append(inventoryitemstr); | |
145 | response += inventoryitemstr; | 145 | tmpresponse.Append(inventoryitemstr.Substring(6,inventoryitemstr.Length - 13)); |
146 | } | 146 | } |
147 | 147 | ||
148 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); | 148 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); |
149 | foreach (UUID bad in bad_folders) | 149 | foreach (UUID bad in bad_folders) |
150 | bad_folders_response += "<uuid>" + bad + "</uuid>"; | 150 | { |
151 | tmpbadfolders.Append("<map><key>folder_id</key><uuid>"); | ||
152 | tmpbadfolders.Append(bad.ToString()); | ||
153 | tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
154 | } | ||
151 | } | 155 | } |
152 | 156 | ||
153 | if (response.Length == 0) | 157 | StringBuilder lastresponse = new StringBuilder(1024); |
158 | lastresponse.Append("<llsd>"); | ||
159 | if(tmpresponse.Length > 0) | ||
154 | { | 160 | { |
155 | /* Viewers expect a bad_folders array when not available */ | 161 | lastresponse.Append("<map><key>folders</key><array>"); |
156 | if (bad_folders_response.Length != 0) | 162 | lastresponse.Append(tmpresponse.ToString()); |
157 | { | 163 | lastresponse.Append("</array></map>"); |
158 | response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
163 | } | ||
164 | } | 164 | } |
165 | else | 165 | else |
166 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
167 | |||
168 | if(tmpbadfolders.Length > 0) | ||
166 | { | 169 | { |
167 | if (bad_folders_response.Length != 0) | 170 | lastresponse.Append("<map><key>bad_folders</key><array>"); |
168 | { | 171 | lastresponse.Append(tmpbadfolders.ToString()); |
169 | response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | 172 | lastresponse.Append("</array></map>"); |
170 | } | ||
171 | else | ||
172 | { | ||
173 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
174 | } | ||
175 | } | 173 | } |
174 | lastresponse.Append("</llsd>"); | ||
176 | 175 | ||
177 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request for {0} folders. Item count {1}", folders.Count, item_count); | 176 | return lastresponse.ToString(); |
178 | //m_log.Debug("[WEB FETCH INV DESC HANDLER] " + response); | ||
179 | |||
180 | return response; | ||
181 | |||
182 | } | 177 | } |
183 | 178 | ||
184 | /// <summary> | 179 | /// <summary> |
@@ -240,24 +235,19 @@ namespace OpenSim.Capabilities.Handlers | |||
240 | return reply; | 235 | return reply; |
241 | } | 236 | } |
242 | 237 | ||
243 | private LLSDInventoryDescendents ToLLSD(InventoryCollection inv, int descendents) | 238 | private LLSDInventoryFolderContents contentsToLLSD(InventoryCollection inv, int descendents) |
244 | { | 239 | { |
245 | LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); | ||
246 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); | 240 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); |
247 | contents.agent_id = inv.OwnerID; | 241 | contents.agent_id = inv.OwnerID; |
248 | contents.owner_id = inv.OwnerID; | 242 | contents.owner_id = inv.OwnerID; |
249 | contents.folder_id = inv.FolderID; | 243 | contents.folder_id = inv.FolderID; |
250 | 244 | ||
251 | reply.folders.Array.Add(contents); | ||
252 | |||
253 | if (inv.Folders != null) | 245 | if (inv.Folders != null) |
254 | { | 246 | { |
255 | foreach (InventoryFolderBase invFolder in inv.Folders) | 247 | foreach (InventoryFolderBase invFolder in inv.Folders) |
256 | { | 248 | { |
257 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); | 249 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); |
258 | } | 250 | } |
259 | |||
260 | descendents += inv.Folders.Count; | ||
261 | } | 251 | } |
262 | 252 | ||
263 | if (inv.Items != null) | 253 | if (inv.Items != null) |
@@ -271,7 +261,7 @@ namespace OpenSim.Capabilities.Handlers | |||
271 | contents.descendents = descendents; | 261 | contents.descendents = descendents; |
272 | contents.version = inv.Version; | 262 | contents.version = inv.Version; |
273 | 263 | ||
274 | return reply; | 264 | return contents; |
275 | } | 265 | } |
276 | /// <summary> | 266 | /// <summary> |
277 | /// Old style. Soon to be deprecated. | 267 | /// Old style. Soon to be deprecated. |
@@ -285,8 +275,8 @@ namespace OpenSim.Capabilities.Handlers | |||
285 | { | 275 | { |
286 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); | 276 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); |
287 | 277 | ||
288 | string response = ""; | 278 | StringBuilder tmpresponse = new StringBuilder(1024); |
289 | string bad_folders_response = ""; | 279 | StringBuilder tmpbadfolders = new StringBuilder(1024); |
290 | 280 | ||
291 | for (int i = 0; i < foldersrequested.Count; i++) | 281 | for (int i = 0; i < foldersrequested.Count; i++) |
292 | { | 282 | { |
@@ -308,7 +298,9 @@ namespace OpenSim.Capabilities.Handlers | |||
308 | 298 | ||
309 | if (null == reply) | 299 | if (null == reply) |
310 | { | 300 | { |
311 | bad_folders_response += "<uuid>" + llsdRequest.folder_id.ToString() + "</uuid>"; | 301 | tmpbadfolders.Append("<map><key>folder_id</key><uuid>"); |
302 | tmpbadfolders.Append(llsdRequest.folder_id.ToString()); | ||
303 | tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
312 | } | 304 | } |
313 | else | 305 | else |
314 | { | 306 | { |
@@ -317,39 +309,29 @@ namespace OpenSim.Capabilities.Handlers | |||
317 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | 309 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); |
318 | } | 310 | } |
319 | 311 | ||
320 | response += inventoryitemstr; | 312 | tmpresponse.Append(inventoryitemstr); |
321 | } | 313 | } |
322 | 314 | ||
323 | if (response.Length == 0) | 315 | StringBuilder lastresponse = new StringBuilder(1024); |
316 | lastresponse.Append("<llsd>"); | ||
317 | if(tmpresponse.Length > 0) | ||
324 | { | 318 | { |
325 | /* Viewers expect a bad_folders array when not available */ | 319 | lastresponse.Append("<map><key>folders</key><array>"); |
326 | if (bad_folders_response.Length != 0) | 320 | lastresponse.Append(tmpresponse.ToString()); |
327 | { | 321 | lastresponse.Append("</array></map>"); |
328 | response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
333 | } | ||
334 | } | 322 | } |
335 | else | 323 | else |
324 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
325 | |||
326 | if(tmpbadfolders.Length > 0) | ||
336 | { | 327 | { |
337 | if (bad_folders_response.Length != 0) | 328 | lastresponse.Append("<map><key>bad_folders</key><array>"); |
338 | { | 329 | lastresponse.Append(tmpbadfolders.ToString()); |
339 | response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | 330 | lastresponse.Append("</array></map>"); |
340 | } | ||
341 | else | ||
342 | { | ||
343 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
344 | } | ||
345 | } | 331 | } |
332 | lastresponse.Append("</llsd>"); | ||
346 | 333 | ||
347 | // m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request"); | 334 | return lastresponse.ToString(); |
348 | //m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response); | ||
349 | |||
350 | return response; | ||
351 | |||
352 | // } | ||
353 | } | 335 | } |
354 | 336 | ||
355 | /// <summary> | 337 | /// <summary> |
@@ -436,108 +418,7 @@ namespace OpenSim.Capabilities.Handlers | |||
436 | itemsToReturn.Insert(0, linkedItem); | 418 | itemsToReturn.Insert(0, linkedItem); |
437 | } | 419 | } |
438 | } | 420 | } |
439 | |||
440 | // Now scan for folder links and insert the items they target and those links at the head of the return data | ||
441 | |||
442 | /* dont send contents of LinkFolders. | ||
443 | from docs seems this was never a spec | ||
444 | |||
445 | foreach (InventoryItemBase item in originalItems) | ||
446 | { | ||
447 | if (item.AssetType == (int)AssetType.LinkFolder) | ||
448 | { | ||
449 | InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID); | ||
450 | List<InventoryItemBase> links = linkedFolderContents.Items; | ||
451 | |||
452 | itemsToReturn.InsertRange(0, links); | ||
453 | |||
454 | foreach (InventoryItemBase link in linkedFolderContents.Items) | ||
455 | { | ||
456 | // Take care of genuinely broken links where the target doesn't exist | ||
457 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
458 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
459 | // rather than having to keep track of every folder requested in the recursion. | ||
460 | if (link != null) | ||
461 | { | ||
462 | // m_log.DebugFormat( | ||
463 | // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}", | ||
464 | // link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name); | ||
465 | |||
466 | InventoryItemBase linkedItem | ||
467 | = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID)); | ||
468 | |||
469 | if (linkedItem != null) | ||
470 | itemsToReturn.Insert(0, linkedItem); | ||
471 | } | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | */ | ||
476 | } | 421 | } |
477 | |||
478 | // foreach (InventoryItemBase item in contents.Items) | ||
479 | // { | ||
480 | // m_log.DebugFormat( | ||
481 | // "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}", | ||
482 | // item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID); | ||
483 | // } | ||
484 | |||
485 | // ===== | ||
486 | |||
487 | // | ||
488 | // foreach (InventoryItemBase linkedItem in linkedItemsToAdd) | ||
489 | // { | ||
490 | // m_log.DebugFormat( | ||
491 | // "[WEB FETCH INV DESC HANDLER]: Inserted linked item {0} for link in folder {1} for agent {2}", | ||
492 | // linkedItem.Name, folderID, agentID); | ||
493 | // | ||
494 | // contents.Items.Add(linkedItem); | ||
495 | // } | ||
496 | // | ||
497 | // // If the folder requested contains links, then we need to send those folders first, otherwise the links | ||
498 | // // will be broken in the viewer. | ||
499 | // HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>(); | ||
500 | // foreach (InventoryItemBase item in contents.Items) | ||
501 | // { | ||
502 | // if (item.AssetType == (int)AssetType.Link) | ||
503 | // { | ||
504 | // InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | ||
505 | // | ||
506 | // // Take care of genuinely broken links where the target doesn't exist | ||
507 | // // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
508 | // // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
509 | // // rather than having to keep track of every folder requested in the recursion. | ||
510 | // if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | ||
511 | // { | ||
512 | // // We don't need to send the folder if source and destination of the link are in the same | ||
513 | // // folder. | ||
514 | // if (linkedItem.Folder != containingFolder.ID) | ||
515 | // linkedItemFolderIdsToSend.Add(linkedItem.Folder); | ||
516 | // } | ||
517 | // } | ||
518 | // } | ||
519 | // | ||
520 | // foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) | ||
521 | // { | ||
522 | // m_log.DebugFormat( | ||
523 | // "[WEB FETCH INV DESC HANDLER]: Recursively fetching folder {0} linked by item in folder {1} for agent {2}", | ||
524 | // linkedItemFolderId, folderID, agentID); | ||
525 | // | ||
526 | // int dummyVersion; | ||
527 | // InventoryCollection linkedCollection | ||
528 | // = Fetch( | ||
529 | // agentID, linkedItemFolderId, ownerID, fetchFolders, fetchItems, sortOrder, out dummyVersion); | ||
530 | // | ||
531 | // InventoryFolderBase linkedFolder = new InventoryFolderBase(linkedItemFolderId); | ||
532 | // linkedFolder.Owner = agentID; | ||
533 | // linkedFolder = m_InventoryService.GetFolder(linkedFolder); | ||
534 | // | ||
535 | //// contents.Folders.AddRange(linkedCollection.Folders); | ||
536 | // | ||
537 | // contents.Folders.Add(linkedFolder); | ||
538 | // contents.Items.AddRange(linkedCollection.Items); | ||
539 | // } | ||
540 | // } | ||
541 | } | 422 | } |
542 | } | 423 | } |
543 | else | 424 | else |
@@ -566,13 +447,14 @@ from docs seems this was never a spec | |||
566 | { | 447 | { |
567 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); | 448 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); |
568 | ret.Collection = new InventoryCollection(); | 449 | ret.Collection = new InventoryCollection(); |
569 | ret.Collection.Folders = new List<InventoryFolderBase>(); | 450 | // ret.Collection.Folders = new List<InventoryFolderBase>(); |
451 | ret.Collection.Folders = fold.RequestListOfFolders(); | ||
570 | ret.Collection.Items = fold.RequestListOfItems(); | 452 | ret.Collection.Items = fold.RequestListOfItems(); |
571 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; | 453 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; |
572 | ret.Collection.FolderID = f.folder_id; | 454 | ret.Collection.FolderID = f.folder_id; |
573 | ret.Collection.Version = fold.Version; | 455 | ret.Collection.Version = fold.Version; |
574 | 456 | ||
575 | ret.Descendents = ret.Collection.Items.Count; | 457 | ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count; |
576 | result.Add(ret); | 458 | result.Add(ret); |
577 | 459 | ||
578 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); | 460 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); |
@@ -594,11 +476,18 @@ from docs seems this was never a spec | |||
594 | 476 | ||
595 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense | 477 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense |
596 | // and can kill the sim (all root folders have parent_id Zero) | 478 | // and can kill the sim (all root folders have parent_id Zero) |
479 | // send something. | ||
597 | LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero); | 480 | LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero); |
598 | if (zero != null) | 481 | if (zero != null) |
599 | { | 482 | { |
600 | fetchFolders.Remove(zero); | 483 | fetchFolders.Remove(zero); |
601 | BadFolder(zero, null, bad_folders); | 484 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); |
485 | zeroColl.Collection = new InventoryCollection(); | ||
486 | zeroColl.Collection.OwnerID = zero.owner_id; | ||
487 | zeroColl.Collection.Version = 0; | ||
488 | zeroColl.Collection.FolderID = zero.folder_id; | ||
489 | zeroColl.Descendents = 0; | ||
490 | result.Add(zeroColl); | ||
602 | } | 491 | } |
603 | 492 | ||
604 | if (fetchFolders.Count > 0) | 493 | if (fetchFolders.Count > 0) |
@@ -666,35 +555,8 @@ from docs seems this was never a spec | |||
666 | } | 555 | } |
667 | else | 556 | else |
668 | { | 557 | { |
669 | // Was it really a request for folder Zero? | 558 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); |
670 | // This is an overkill, but Firestorm really asks for folder Zero. | 559 | bad_folders.Add(freq.folder_id); |
671 | // I'm leaving the code here for the time being, but commented. | ||
672 | if (freq.folder_id == UUID.Zero) | ||
673 | { | ||
674 | //coll.Collection.OwnerID = freq.owner_id; | ||
675 | //coll.Collection.FolderID = contents.FolderID; | ||
676 | //containingFolder = m_InventoryService.GetRootFolder(freq.owner_id); | ||
677 | //if (containingFolder != null) | ||
678 | //{ | ||
679 | // m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Request for parent of folder {0}", containingFolder.ID); | ||
680 | // coll.Collection.Folders.Clear(); | ||
681 | // coll.Collection.Folders.Add(containingFolder); | ||
682 | // if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | ||
683 | // { | ||
684 | // InventoryFolderBase lib = new InventoryFolderBase(m_LibraryService.LibraryRootFolder.ID, m_LibraryService.LibraryRootFolder.Owner); | ||
685 | // lib.Name = m_LibraryService.LibraryRootFolder.Name; | ||
686 | // lib.Type = m_LibraryService.LibraryRootFolder.Type; | ||
687 | // lib.Version = m_LibraryService.LibraryRootFolder.Version; | ||
688 | // coll.Collection.Folders.Add(lib); | ||
689 | // } | ||
690 | // coll.Collection.Items.Clear(); | ||
691 | //} | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); | ||
696 | bad_folders.Add(freq.folder_id); | ||
697 | } | ||
698 | bad = true; | 560 | bad = true; |
699 | } | 561 | } |
700 | } | 562 | } |
@@ -708,42 +570,21 @@ from docs seems this was never a spec | |||
708 | 570 | ||
709 | if (freq.fetch_items && contents.Items != null) | 571 | if (freq.fetch_items && contents.Items != null) |
710 | { | 572 | { |
711 | List<InventoryItemBase> itemsToReturn = contents.Items; | 573 | // viewers are lasy and want a copy of the linked item sent before the link to it |
712 | 574 | ||
713 | // descendents must only include the links, not the linked items we add | 575 | // descendents must only include the links, not the linked items we add |
714 | coll.Descendents = itemsToReturn.Count; | 576 | coll.Descendents = contents.Items.Count + contents.Folders.Count; |
715 | 577 | ||
716 | // Add target items for links in this folder before the links themselves. | 578 | // look for item links |
717 | List<UUID> itemIDs = new List<UUID>(); | 579 | List<UUID> itemIDs = new List<UUID>(); |
718 | List<UUID> folderIDs = new List<UUID>(); | 580 | foreach (InventoryItemBase item in contents.Items) |
719 | foreach (InventoryItemBase item in itemsToReturn) | ||
720 | { | 581 | { |
721 | //m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType); | 582 | //m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType); |
722 | if (item.AssetType == (int)AssetType.Link) | 583 | if (item.AssetType == (int)AssetType.Link) |
723 | itemIDs.Add(item.AssetID); | 584 | itemIDs.Add(item.AssetID); |
724 | |||
725 | // else if (item.AssetType == (int)AssetType.LinkFolder) | ||
726 | // folderIDs.Add(item.AssetID); | ||
727 | } | ||
728 | |||
729 | //m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count); | ||
730 | |||
731 | // Scan for folder links and insert the items they target and those links at the head of the return data | ||
732 | if (folderIDs.Count > 0) | ||
733 | { | ||
734 | InventoryCollection[] linkedFolders = m_InventoryService.GetMultipleFoldersContent(coll.Collection.OwnerID, folderIDs.ToArray()); | ||
735 | foreach (InventoryCollection linkedFolderContents in linkedFolders) | ||
736 | { | ||
737 | if (linkedFolderContents == null) | ||
738 | continue; | ||
739 | |||
740 | List<InventoryItemBase> links = linkedFolderContents.Items; | ||
741 | |||
742 | itemsToReturn.InsertRange(0, links); | ||
743 | |||
744 | } | ||
745 | } | 585 | } |
746 | 586 | ||
587 | // get the linked if any | ||
747 | if (itemIDs.Count > 0) | 588 | if (itemIDs.Count > 0) |
748 | { | 589 | { |
749 | InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray()); | 590 | InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray()); |
@@ -758,13 +599,11 @@ from docs seems this was never a spec | |||
758 | linked[i++] = m_InventoryService.GetItem(freq.owner_id, id); | 599 | linked[i++] = m_InventoryService.GetItem(freq.owner_id, id); |
759 | } | 600 | } |
760 | } | 601 | } |
761 | 602 | ||
762 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Processing folder {0}. Existing items:", freq.folder_id); | ||
763 | //foreach (InventoryItemBase item in itemsToReturn) | ||
764 | // m_log.DebugFormat("[XXX]: {0} {1} {2}", item.Name, item.AssetType, item.Folder); | ||
765 | |||
766 | if (linked != null) | 603 | if (linked != null) |
767 | { | 604 | { |
605 | List<InventoryItemBase> linkedItems = new List<InventoryItemBase>(); | ||
606 | // check for broken | ||
768 | foreach (InventoryItemBase linkedItem in linked) | 607 | foreach (InventoryItemBase linkedItem in linked) |
769 | { | 608 | { |
770 | // Take care of genuinely broken links where the target doesn't exist | 609 | // Take care of genuinely broken links where the target doesn't exist |
@@ -773,14 +612,16 @@ from docs seems this was never a spec | |||
773 | // rather than having to keep track of every folder requested in the recursion. | 612 | // rather than having to keep track of every folder requested in the recursion. |
774 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | 613 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) |
775 | { | 614 | { |
776 | itemsToReturn.Insert(0, linkedItem); | 615 | linkedItems.Add(linkedItem); |
777 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder); | 616 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder); |
778 | } | 617 | } |
779 | } | 618 | } |
619 | // insert them | ||
620 | if(linkedItems.Count > 0) | ||
621 | contents.Items.InsertRange(0,linkedItems); | ||
780 | } | 622 | } |
781 | } | 623 | } |
782 | } | 624 | } |
783 | |||
784 | } | 625 | } |
785 | 626 | ||
786 | /// <summary> | 627 | /// <summary> |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 8ad7b0d..4b88923 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console | |||
234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
235 | 235 | ||
236 | m_Server.AddPollServiceHTTPHandler( | 236 | m_Server.AddPollServiceHTTPHandler( |
237 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 237 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, Drop, sessionID, 25000)); // 25 secs timeout |
238 | 238 | ||
239 | XmlDocument xmldoc = new XmlDocument(); | 239 | XmlDocument xmldoc = new XmlDocument(); |
240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
@@ -425,6 +425,15 @@ namespace OpenSim.Framework.Console | |||
425 | return false; | 425 | return false; |
426 | } | 426 | } |
427 | 427 | ||
428 | private void Drop(UUID RequestID, UUID sessionID) | ||
429 | { | ||
430 | lock (m_Connections) | ||
431 | { | ||
432 | if (m_Connections.ContainsKey(sessionID)) | ||
433 | m_Connections.Remove(sessionID); | ||
434 | } | ||
435 | } | ||
436 | |||
428 | private Hashtable GetEvents(UUID RequestID, UUID sessionID) | 437 | private Hashtable GetEvents(UUID RequestID, UUID sessionID) |
429 | { | 438 | { |
430 | ConsoleConnection c = null; | 439 | ConsoleConnection c = null; |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 3fd3bf7..a9860cc 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -37,6 +37,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); | 37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); |
38 | 38 | ||
39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); | 39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); |
40 | public delegate void DropMethod(UUID requestID, UUID pId); | ||
40 | 41 | ||
41 | public class PollServiceEventArgs : EventArgs | 42 | public class PollServiceEventArgs : EventArgs |
42 | { | 43 | { |
@@ -44,6 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
44 | public GetEventsMethod GetEvents; | 45 | public GetEventsMethod GetEvents; |
45 | public NoEventsMethod NoEvents; | 46 | public NoEventsMethod NoEvents; |
46 | public RequestMethod Request; | 47 | public RequestMethod Request; |
48 | public DropMethod Drop; | ||
47 | public UUID Id; | 49 | public UUID Id; |
48 | public int TimeOutms; | 50 | public int TimeOutms; |
49 | public EventType Type; | 51 | public EventType Type; |
@@ -73,13 +75,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
73 | RequestMethod pRequest, | 75 | RequestMethod pRequest, |
74 | string pUrl, | 76 | string pUrl, |
75 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, | 77 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, |
76 | UUID pId, int pTimeOutms) | 78 | DropMethod pDrop, UUID pId, int pTimeOutms) |
77 | { | 79 | { |
78 | Request = pRequest; | 80 | Request = pRequest; |
79 | Url = pUrl; | 81 | Url = pUrl; |
80 | HasEvents = pHasEvents; | 82 | HasEvents = pHasEvents; |
81 | GetEvents = pGetEvents; | 83 | GetEvents = pGetEvents; |
82 | NoEvents = pNoEvents; | 84 | NoEvents = pNoEvents; |
85 | Drop = pDrop; | ||
83 | Id = pId; | 86 | Id = pId; |
84 | TimeOutms = pTimeOutms; | 87 | TimeOutms = pTimeOutms; |
85 | Type = EventType.LongPoll; | 88 | Type = EventType.LongPoll; |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 0e4a941..9083e12 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -47,8 +47,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
47 | public readonly UUID RequestID; | 47 | public readonly UUID RequestID; |
48 | public int contextHash; | 48 | public int contextHash; |
49 | 49 | ||
50 | /* | ||
50 | private void GenContextHash() | 51 | private void GenContextHash() |
51 | { | 52 | { |
53 | |||
52 | Random rnd = new Random(); | 54 | Random rnd = new Random(); |
53 | contextHash = 0; | 55 | contextHash = 0; |
54 | if (Request.Headers["remote_addr"] != null) | 56 | if (Request.Headers["remote_addr"] != null) |
@@ -62,8 +64,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
62 | } | 64 | } |
63 | else | 65 | else |
64 | contextHash += rnd.Next() & 0xffff; | 66 | contextHash += rnd.Next() & 0xffff; |
65 | } | ||
66 | 67 | ||
68 | } | ||
69 | */ | ||
67 | public PollServiceHttpRequest( | 70 | public PollServiceHttpRequest( |
68 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) | 71 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) |
69 | { | 72 | { |
@@ -72,7 +75,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
72 | Request = pRequest; | 75 | Request = pRequest; |
73 | RequestTime = System.Environment.TickCount; | 76 | RequestTime = System.Environment.TickCount; |
74 | RequestID = UUID.Random(); | 77 | RequestID = UUID.Random(); |
75 | GenContextHash(); | 78 | // GenContextHash(); |
79 | contextHash = HttpContext.contextID; | ||
76 | } | 80 | } |
77 | 81 | ||
78 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | 82 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) |
@@ -132,8 +136,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
132 | { | 136 | { |
133 | if (b1.contextHash != b2.contextHash) | 137 | if (b1.contextHash != b2.contextHash) |
134 | return false; | 138 | return false; |
135 | bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext); | 139 | // bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext); |
136 | return b; | 140 | // return b; |
141 | return true; | ||
137 | } | 142 | } |
138 | 143 | ||
139 | public int GetHashCode(PollServiceHttpRequest b2) | 144 | public int GetHashCode(PollServiceHttpRequest b2) |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index ffcad0f..5b40590 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -160,6 +160,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | public void DropByContext(PollServiceHttpRequest req) | ||
164 | { | ||
165 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
166 | lock (m_bycontext) | ||
167 | { | ||
168 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | ||
169 | { | ||
170 | ctxQeueue.Clear(); | ||
171 | m_bycontext.Remove(req); | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | |||
163 | public void EnqueueInt(PollServiceHttpRequest req) | 176 | public void EnqueueInt(PollServiceHttpRequest req) |
164 | { | 177 | { |
165 | if (m_running) | 178 | if (m_running) |
@@ -263,22 +276,61 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
263 | PollServiceHttpRequest req = m_requests.Dequeue(5000); | 276 | PollServiceHttpRequest req = m_requests.Dequeue(5000); |
264 | 277 | ||
265 | Watchdog.UpdateThread(); | 278 | Watchdog.UpdateThread(); |
266 | if (req != null) | 279 | if(req == null) |
280 | continue; | ||
281 | |||
282 | try | ||
267 | { | 283 | { |
268 | try | 284 | if(!req.HttpContext.CanSend()) |
269 | { | 285 | { |
270 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 286 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
287 | byContextDequeue(req); | ||
288 | continue; | ||
289 | } | ||
290 | |||
291 | if(req.HttpContext.IsSending()) | ||
292 | { | ||
293 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
271 | { | 294 | { |
272 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 295 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
296 | byContextDequeue(req); | ||
297 | } | ||
298 | else | ||
299 | ReQueueEvent(req); | ||
300 | continue; | ||
301 | } | ||
273 | 302 | ||
303 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
304 | { | ||
305 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
306 | |||
307 | m_threadPool.QueueWorkItem(x => | ||
308 | { | ||
309 | try | ||
310 | { | ||
311 | req.DoHTTPGruntWork(m_server, responsedata); | ||
312 | byContextDequeue(req); | ||
313 | } | ||
314 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | ||
315 | { | ||
316 | // Ignore it, no need to reply | ||
317 | } | ||
318 | return null; | ||
319 | }, null); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
324 | { | ||
274 | m_threadPool.QueueWorkItem(x => | 325 | m_threadPool.QueueWorkItem(x => |
275 | { | 326 | { |
276 | try | 327 | try |
277 | { | 328 | { |
278 | req.DoHTTPGruntWork(m_server, responsedata); | 329 | req.DoHTTPGruntWork(m_server, |
330 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
279 | byContextDequeue(req); | 331 | byContextDequeue(req); |
280 | } | 332 | } |
281 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | 333 | catch (ObjectDisposedException) |
282 | { | 334 | { |
283 | // Ignore it, no need to reply | 335 | // Ignore it, no need to reply |
284 | } | 336 | } |
@@ -287,36 +339,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
287 | } | 339 | } |
288 | else | 340 | else |
289 | { | 341 | { |
290 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 342 | ReQueueEvent(req); |
291 | { | ||
292 | m_threadPool.QueueWorkItem(x => | ||
293 | { | ||
294 | try | ||
295 | { | ||
296 | req.DoHTTPGruntWork(m_server, | ||
297 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
298 | byContextDequeue(req); | ||
299 | } | ||
300 | catch (ObjectDisposedException) | ||
301 | { | ||
302 | // Ignore it, no need to reply | ||
303 | } | ||
304 | return null; | ||
305 | }, null); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | ReQueueEvent(req); | ||
310 | } | ||
311 | } | 343 | } |
312 | } | 344 | } |
313 | catch (Exception e) | 345 | } |
314 | { | 346 | catch (Exception e) |
315 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 347 | { |
316 | } | 348 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
317 | } | 349 | } |
318 | } | 350 | } |
319 | } | 351 | } |
320 | |||
321 | } | 352 | } |
322 | } | 353 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 6d548ad..f3acacd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -372,7 +372,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
372 | 372 | ||
373 | caps.RegisterPollHandler( | 373 | caps.RegisterPollHandler( |
374 | "EventQueueGet", | 374 | "EventQueueGet", |
375 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); | 375 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, SERVER_EQ_TIME_NO_EVENTS)); |
376 | } | 376 | } |
377 | 377 | ||
378 | public bool HasEvents(UUID requestID, UUID agentID) | 378 | public bool HasEvents(UUID requestID, UUID agentID) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index f66ef57..783c3de 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -222,11 +222,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
222 | new List<Hashtable>(); | 222 | new List<Hashtable>(); |
223 | private Dictionary<UUID, aPollResponse> responses = | 223 | private Dictionary<UUID, aPollResponse> responses = |
224 | new Dictionary<UUID, aPollResponse>(); | 224 | new Dictionary<UUID, aPollResponse>(); |
225 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); | ||
225 | 226 | ||
226 | private Scene m_scene; | 227 | private Scene m_scene; |
227 | private MeshCapsDataThrottler m_throttler; | 228 | private MeshCapsDataThrottler m_throttler; |
228 | public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : | 229 | public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : |
229 | base(null, uri, null, null, null, pId, int.MaxValue) | 230 | base(null, uri, null, null, null, null, pId, int.MaxValue) |
230 | { | 231 | { |
231 | m_scene = scene; | 232 | m_scene = scene; |
232 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); | 233 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); |
@@ -241,6 +242,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
241 | 242 | ||
242 | } | 243 | } |
243 | }; | 244 | }; |
245 | |||
246 | Drop = (x, y) => | ||
247 | { | ||
248 | lock (responses) | ||
249 | { | ||
250 | responses.Remove(x); | ||
251 | lock(dropedResponses) | ||
252 | dropedResponses.Add(x); | ||
253 | } | ||
254 | }; | ||
255 | |||
244 | GetEvents = (x, y) => | 256 | GetEvents = (x, y) => |
245 | { | 257 | { |
246 | lock (responses) | 258 | lock (responses) |
@@ -298,26 +310,47 @@ namespace OpenSim.Region.ClientStack.Linden | |||
298 | if(m_scene.ShuttingDown) | 310 | if(m_scene.ShuttingDown) |
299 | return; | 311 | return; |
300 | 312 | ||
301 | // If the avatar is gone, don't bother to get the texture | 313 | lock(responses) |
302 | if (m_scene.GetScenePresence(Id) == null) | ||
303 | { | 314 | { |
304 | response = new Hashtable(); | 315 | lock(dropedResponses) |
316 | { | ||
317 | if(dropedResponses.Contains(requestID)) | ||
318 | { | ||
319 | dropedResponses.Remove(requestID); | ||
320 | return; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | // If the avatar is gone, don't bother to get the texture | ||
325 | if (m_scene.GetScenePresence(Id) == null) | ||
326 | { | ||
327 | response = new Hashtable(); | ||
305 | 328 | ||
306 | response["int_response_code"] = 500; | 329 | response["int_response_code"] = 500; |
307 | response["str_response_string"] = "Script timeout"; | 330 | response["str_response_string"] = "Script timeout"; |
308 | response["content_type"] = "text/plain"; | 331 | response["content_type"] = "text/plain"; |
309 | response["keepalive"] = false; | 332 | response["keepalive"] = false; |
310 | response["reusecontext"] = false; | 333 | response["reusecontext"] = false; |
311 | 334 | ||
312 | lock (responses) | ||
313 | responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; | 335 | responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; |
314 | 336 | ||
315 | return; | 337 | return; |
338 | } | ||
316 | } | 339 | } |
317 | 340 | ||
318 | response = m_getMeshHandler.Handle(requestinfo.request); | 341 | response = m_getMeshHandler.Handle(requestinfo.request); |
342 | |||
319 | lock (responses) | 343 | lock (responses) |
320 | { | 344 | { |
345 | lock(dropedResponses) | ||
346 | { | ||
347 | if(dropedResponses.Contains(requestID)) | ||
348 | { | ||
349 | dropedResponses.Remove(requestID); | ||
350 | return; | ||
351 | } | ||
352 | } | ||
353 | |||
321 | responses[requestID] = new aPollResponse() | 354 | responses[requestID] = new aPollResponse() |
322 | { | 355 | { |
323 | bytes = (int)response["int_bytes"], | 356 | bytes = (int)response["int_bytes"], |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 14a59fe..15c0967 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -218,11 +218,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
218 | new List<Hashtable>(); | 218 | new List<Hashtable>(); |
219 | private Dictionary<UUID, aPollResponse> responses = | 219 | private Dictionary<UUID, aPollResponse> responses = |
220 | new Dictionary<UUID, aPollResponse>(); | 220 | new Dictionary<UUID, aPollResponse>(); |
221 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); | ||
221 | 222 | ||
222 | private Scene m_scene; | 223 | private Scene m_scene; |
223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); | 224 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); |
224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : | 225 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : |
225 | base(null, "", null, null, null, pId, int.MaxValue) | 226 | base(null, "", null, null, null, null, pId, int.MaxValue) |
226 | { | 227 | { |
227 | m_scene = scene; | 228 | m_scene = scene; |
228 | // x is request id, y is userid | 229 | // x is request id, y is userid |
@@ -236,6 +237,16 @@ namespace OpenSim.Region.ClientStack.Linden | |||
236 | 237 | ||
237 | } | 238 | } |
238 | }; | 239 | }; |
240 | |||
241 | Drop = (x, y) => | ||
242 | { | ||
243 | lock (responses) | ||
244 | { | ||
245 | responses.Remove(x); | ||
246 | dropedResponses.Add(x); | ||
247 | } | ||
248 | }; | ||
249 | |||
239 | GetEvents = (x, y) => | 250 | GetEvents = (x, y) => |
240 | { | 251 | { |
241 | lock (responses) | 252 | lock (responses) |
@@ -304,52 +315,71 @@ namespace OpenSim.Region.ClientStack.Linden | |||
304 | if(m_scene.ShuttingDown) | 315 | if(m_scene.ShuttingDown) |
305 | return; | 316 | return; |
306 | 317 | ||
307 | if (requestinfo.send503) | 318 | lock (responses) |
308 | { | 319 | { |
309 | response = new Hashtable(); | 320 | lock(dropedResponses) |
321 | { | ||
322 | if(dropedResponses.Contains(requestID)) | ||
323 | { | ||
324 | dropedResponses.Remove(requestID); | ||
325 | return; | ||
326 | } | ||
327 | } | ||
310 | 328 | ||
311 | response["int_response_code"] = 503; | 329 | if (requestinfo.send503) |
312 | response["str_response_string"] = "Throttled"; | 330 | { |
313 | response["content_type"] = "text/plain"; | 331 | response = new Hashtable(); |
314 | response["keepalive"] = false; | ||
315 | response["reusecontext"] = false; | ||
316 | 332 | ||
317 | Hashtable headers = new Hashtable(); | 333 | response["int_response_code"] = 503; |
318 | headers["Retry-After"] = 30; | 334 | response["str_response_string"] = "Throttled"; |
319 | response["headers"] = headers; | 335 | response["content_type"] = "text/plain"; |
320 | 336 | response["keepalive"] = false; | |
321 | lock (responses) | 337 | response["reusecontext"] = false; |
338 | |||
339 | Hashtable headers = new Hashtable(); | ||
340 | headers["Retry-After"] = 30; | ||
341 | response["headers"] = headers; | ||
342 | |||
322 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; | 343 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; |
323 | 344 | ||
324 | return; | 345 | return; |
325 | } | 346 | } |
326 | 347 | ||
327 | // If the avatar is gone, don't bother to get the texture | 348 | // If the avatar is gone, don't bother to get the texture |
328 | if (m_scene.GetScenePresence(Id) == null) | 349 | if (m_scene.GetScenePresence(Id) == null) |
329 | { | 350 | { |
330 | response = new Hashtable(); | 351 | response = new Hashtable(); |
331 | 352 | ||
332 | response["int_response_code"] = 500; | 353 | response["int_response_code"] = 500; |
333 | response["str_response_string"] = "Script timeout"; | 354 | response["str_response_string"] = "Script timeout"; |
334 | response["content_type"] = "text/plain"; | 355 | response["content_type"] = "text/plain"; |
335 | response["keepalive"] = false; | 356 | response["keepalive"] = false; |
336 | response["reusecontext"] = false; | 357 | response["reusecontext"] = false; |
337 | 358 | ||
338 | lock (responses) | ||
339 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; | 359 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; |
340 | 360 | ||
341 | return; | 361 | return; |
362 | } | ||
342 | } | 363 | } |
343 | 364 | ||
344 | response = m_getTextureHandler.Handle(requestinfo.request); | 365 | response = m_getTextureHandler.Handle(requestinfo.request); |
366 | |||
345 | lock (responses) | 367 | lock (responses) |
346 | { | 368 | { |
369 | lock(dropedResponses) | ||
370 | { | ||
371 | if(dropedResponses.Contains(requestID)) | ||
372 | { | ||
373 | dropedResponses.Remove(requestID); | ||
374 | m_throttler.ProcessTime(); | ||
375 | return; | ||
376 | } | ||
377 | } | ||
347 | responses[requestID] = new aPollResponse() | 378 | responses[requestID] = new aPollResponse() |
348 | { | 379 | { |
349 | bytes = (int) response["int_bytes"], | 380 | bytes = (int) response["int_bytes"], |
350 | response = response | 381 | response = response |
351 | }; | 382 | }; |
352 | |||
353 | } | 383 | } |
354 | m_throttler.ProcessTime(); | 384 | m_throttler.ProcessTime(); |
355 | } | 385 | } |
@@ -423,7 +453,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
423 | 453 | ||
424 | internal sealed class CapsDataThrottler | 454 | internal sealed class CapsDataThrottler |
425 | { | 455 | { |
426 | |||
427 | private volatile int currenttime = 0; | 456 | private volatile int currenttime = 0; |
428 | private volatile int lastTimeElapsed = 0; | 457 | private volatile int lastTimeElapsed = 0; |
429 | private volatile int BytesSent = 0; | 458 | private volatile int BytesSent = 0; |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index ba4fb76..0277a24 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -61,7 +61,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
61 | public UUID reqID; | 61 | public UUID reqID; |
62 | public Hashtable request; | 62 | public Hashtable request; |
63 | public ScenePresence presence; | 63 | public ScenePresence presence; |
64 | public List<UUID> folders; | ||
65 | } | 64 | } |
66 | 65 | ||
67 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -250,17 +249,28 @@ namespace OpenSim.Region.ClientStack.Linden | |||
250 | { | 249 | { |
251 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 250 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
252 | 251 | ||
253 | private Dictionary<UUID, Hashtable> responses = | 252 | private Dictionary<UUID, Hashtable> responses = new Dictionary<UUID, Hashtable>(); |
254 | new Dictionary<UUID, Hashtable>(); | 253 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); |
255 | 254 | ||
256 | private WebFetchInvDescModule m_module; | 255 | private WebFetchInvDescModule m_module; |
257 | 256 | ||
258 | public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : | 257 | public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : |
259 | base(null, url, null, null, null, pId, int.MaxValue) | 258 | base(null, url, null, null, null, null, pId, int.MaxValue) |
260 | { | 259 | { |
261 | m_module = module; | 260 | m_module = module; |
262 | 261 | ||
263 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; | 262 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; |
263 | |||
264 | Drop = (x, y) => | ||
265 | { | ||
266 | lock (responses) | ||
267 | { | ||
268 | responses.Remove(x); | ||
269 | lock(dropedResponses) | ||
270 | dropedResponses.Add(x); | ||
271 | } | ||
272 | }; | ||
273 | |||
264 | GetEvents = (x, y) => | 274 | GetEvents = (x, y) => |
265 | { | 275 | { |
266 | lock (responses) | 276 | lock (responses) |
@@ -285,8 +295,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
285 | reqinfo.reqID = x; | 295 | reqinfo.reqID = x; |
286 | reqinfo.request = y; | 296 | reqinfo.request = y; |
287 | reqinfo.presence = sp; | 297 | reqinfo.presence = sp; |
288 | reqinfo.folders = new List<UUID>(); | ||
289 | 298 | ||
299 | /* why where we doing this? just to get cof ? | ||
300 | List<UUID> folders = new List<UUID>(); | ||
301 | |||
290 | // Decode the request here | 302 | // Decode the request here |
291 | string request = y["body"].ToString(); | 303 | string request = y["body"].ToString(); |
292 | 304 | ||
@@ -322,11 +334,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
322 | UUID folderID; | 334 | UUID folderID; |
323 | if (UUID.TryParse(folder, out folderID)) | 335 | if (UUID.TryParse(folder, out folderID)) |
324 | { | 336 | { |
325 | if (!reqinfo.folders.Contains(folderID)) | 337 | if (!folders.Contains(folderID)) |
326 | { | 338 | { |
327 | if (sp.COF != UUID.Zero && sp.COF == folderID) | 339 | if (sp.COF != UUID.Zero && sp.COF == folderID) |
328 | highPriority = true; | 340 | highPriority = true; |
329 | reqinfo.folders.Add(folderID); | 341 | folders.Add(folderID); |
330 | } | 342 | } |
331 | } | 343 | } |
332 | } | 344 | } |
@@ -334,6 +346,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
334 | if (highPriority) | 346 | if (highPriority) |
335 | m_queue.PriorityEnqueue(reqinfo); | 347 | m_queue.PriorityEnqueue(reqinfo); |
336 | else | 348 | else |
349 | */ | ||
337 | m_queue.Enqueue(reqinfo); | 350 | m_queue.Enqueue(reqinfo); |
338 | }; | 351 | }; |
339 | 352 | ||
@@ -365,6 +378,19 @@ namespace OpenSim.Region.ClientStack.Linden | |||
365 | 378 | ||
366 | UUID requestID = requestinfo.reqID; | 379 | UUID requestID = requestinfo.reqID; |
367 | 380 | ||
381 | |||
382 | lock(responses) | ||
383 | { | ||
384 | lock(dropedResponses) | ||
385 | { | ||
386 | if(dropedResponses.Contains(requestID)) | ||
387 | { | ||
388 | dropedResponses.Remove(requestID); | ||
389 | return; | ||
390 | } | ||
391 | } | ||
392 | } | ||
393 | |||
368 | Hashtable response = new Hashtable(); | 394 | Hashtable response = new Hashtable(); |
369 | 395 | ||
370 | response["int_response_code"] = 200; | 396 | response["int_response_code"] = 200; |
@@ -377,11 +403,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
377 | 403 | ||
378 | lock (responses) | 404 | lock (responses) |
379 | { | 405 | { |
406 | lock(dropedResponses) | ||
407 | { | ||
408 | if(dropedResponses.Contains(requestID)) | ||
409 | { | ||
410 | dropedResponses.Remove(requestID); | ||
411 | requestinfo.request.Clear(); | ||
412 | WebFetchInvDescModule.ProcessedRequestsCount++; | ||
413 | return; | ||
414 | } | ||
415 | } | ||
416 | |||
380 | if (responses.ContainsKey(requestID)) | 417 | if (responses.ContainsKey(requestID)) |
381 | m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); | 418 | m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); |
382 | responses[requestID] = response; | 419 | responses[requestID] = response; |
383 | } | 420 | } |
384 | requestinfo.folders.Clear(); | ||
385 | requestinfo.request.Clear(); | 421 | requestinfo.request.Clear(); |
386 | WebFetchInvDescModule.ProcessedRequestsCount++; | 422 | WebFetchInvDescModule.ProcessedRequestsCount++; |
387 | } | 423 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f563c68..c118f33 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
225 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; | 225 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; |
226 | 226 | ||
227 | PollServiceEventArgs args | 227 | PollServiceEventArgs args |
228 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 228 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); |
229 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 229 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
230 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); | 230 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
231 | 231 | ||
@@ -276,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
276 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 276 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; |
277 | 277 | ||
278 | PollServiceEventArgs args | 278 | PollServiceEventArgs args |
279 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 279 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); |
280 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 280 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
281 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); | 281 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
282 | 282 | ||
@@ -530,6 +530,28 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
530 | } | 530 | } |
531 | } | 531 | } |
532 | } | 532 | } |
533 | |||
534 | private void Drop(UUID requestID, UUID sessionID) | ||
535 | { | ||
536 | UrlData url = null; | ||
537 | lock (m_RequestMap) | ||
538 | { | ||
539 | if (m_RequestMap.ContainsKey(requestID)) | ||
540 | { | ||
541 | url = m_RequestMap[requestID]; | ||
542 | m_RequestMap.Remove(requestID); | ||
543 | if(url != null) | ||
544 | { | ||
545 | lock (url.requests) | ||
546 | { | ||
547 | if(url.requests.ContainsKey(requestID)) | ||
548 | url.requests.Remove(requestID); | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | |||
533 | private Hashtable GetEvents(UUID requestID, UUID sessionID) | 555 | private Hashtable GetEvents(UUID requestID, UUID sessionID) |
534 | { | 556 | { |
535 | UrlData url = null; | 557 | UrlData url = null; |
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 9643a8b..3c77924 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs | |||
@@ -275,6 +275,7 @@ namespace OpenSim.Services.HypergridService | |||
275 | 275 | ||
276 | if (!am.Success) | 276 | if (!am.Success) |
277 | { | 277 | { |
278 | reason = "Login failed: client " + curViewer + " is not allowed"; | ||
278 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); | 279 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer); |
279 | return false; | 280 | return false; |
280 | } | 281 | } |
@@ -287,6 +288,7 @@ namespace OpenSim.Services.HypergridService | |||
287 | 288 | ||
288 | if (dm.Success) | 289 | if (dm.Success) |
289 | { | 290 | { |
291 | reason = "Login failed: client " + curViewer + " is denied"; | ||
290 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); | 292 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer); |
291 | return false; | 293 | return false; |
292 | } | 294 | } |