Mantis #7567. One of the reported log messages showed this:

09:38:40 - [LOGHTTP]: Slow handling of 15572 POST /CAPS/b12c7e98-8261-4953-b7d1-1c414c9893fc FetchInventory2 8acfbca3-13b5-434f-898c-5f4bbe8a76ff from 92.237.199.112:60083 took 62391ms
FetchInventory itself wasn't taking advantage of the new inventory API. This commit fixes that.
fsassets
Diva Canto 2015-06-02 15:40:13 -07:00
parent 8de65a8fb3
commit be6fb22d69
1 changed files with 26 additions and 3 deletions

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
@ -34,11 +35,13 @@ using OpenSim.Services.Interfaces;
using OSDArray = OpenMetaverse.StructuredData.OSDArray; using OSDArray = OpenMetaverse.StructuredData.OSDArray;
using OSDMap = OpenMetaverse.StructuredData.OSDMap; using OSDMap = OpenMetaverse.StructuredData.OSDMap;
using log4net;
namespace OpenSim.Capabilities.Handlers namespace OpenSim.Capabilities.Handlers
{ {
public class FetchInventory2Handler public class FetchInventory2Handler
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IInventoryService m_inventoryService; private IInventoryService m_inventoryService;
private UUID m_agentID; private UUID m_agentID;
@ -59,12 +62,32 @@ namespace OpenSim.Capabilities.Handlers
string reply; string reply;
LLSDFetchInventory llsdReply = new LLSDFetchInventory(); LLSDFetchInventory llsdReply = new LLSDFetchInventory();
UUID[] itemIDs = new UUID[itemsRequested.Count];
int i = 0;
foreach (OSDMap osdItemId in itemsRequested) foreach (OSDMap osdItemId in itemsRequested)
{ {
UUID itemId = osdItemId["item_id"].AsUUID(); itemIDs[i++] = osdItemId["item_id"].AsUUID();
}
InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId, m_agentID)); InventoryItemBase[] items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
if (items == null)
{
// OMG!!! One by one!!! This is fallback code, in case the backend isn't updated
m_log.WarnFormat("[FETCH INVENTORY HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one.");
items = new InventoryItemBase[itemsRequested.Count];
i = 0;
InventoryItemBase item = new InventoryItemBase();
item.Owner = m_agentID;
foreach (UUID id in itemIDs)
{
item.ID = id;
items[i++] = m_inventoryService.GetItem(item);
}
}
foreach (InventoryItemBase item in items)
{
if (item != null) if (item != null)
{ {
// We don't know the agent that this request belongs to so we'll use the agent id of the item // We don't know the agent that this request belongs to so we'll use the agent id of the item