From 06e4297b93bb5c60b06e921200a39d2a6fcb1cd0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 26 Jul 2009 19:09:59 +0000 Subject: Patch from RemedyTomm: A failed inventory request would block any further requests from that same user, even after a relog. This patch changes the block on further requests to be in line with the request timeout timer and allows the system to recover. --- .../Inventory/InventoryServiceConnector.cs | 49 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 50ce3ea..ae15cfb 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -47,6 +47,7 @@ namespace OpenSim.Services.Connectors private string m_ServerURI = String.Empty; private Dictionary m_RequestingInventory = new Dictionary(); + private Dictionary m_RequestTime = new Dictionary(); public InventoryServicesConnector() { @@ -102,12 +103,43 @@ namespace OpenSim.Services.Connectors { lock (m_RequestingInventory) { - if (!m_RequestingInventory.ContainsKey(userID)) - m_RequestingInventory.Add(userID, callback); - else + // *HACK ALERT* + + // If an inventory request times out, it blocks any further requests from the + // same user, even after a relog. This is bad, and makes me sad. + + // Really, we should detect a timeout and report a failure to the callback, + // BUT in my testing i found that it's hard to detect a timeout.. sometimes, + // a partial response is recieved, and sometimes a null response. + + // So, for now, add a timer of ten seconds (which is the request timeout). + + // This should basically have the same effect. + + lock (m_RequestTime) { - m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetUserInventory - ignoring repeated request for user {0}", userID); - return; + if (m_RequestTime.ContainsKey(userID)) + { + TimeSpan interval = DateTime.Now - m_RequestTime[userID]; + if (interval.TotalSeconds > 10) + { + m_RequestTime.Remove(userID); + if (m_RequestingInventory.ContainsKey(userID)) + { + m_RequestingInventory.Remove(userID); + } + } + } + if (!m_RequestingInventory.ContainsKey(userID)) + { + m_RequestTime.Add(userID, DateTime.Now); + m_RequestingInventory.Add(userID, callback); + } + else + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetUserInventory - ignoring repeated request for user {0}", userID); + return; + } } } @@ -283,6 +315,13 @@ namespace OpenSim.Services.Connectors { callback = m_RequestingInventory[userID]; m_RequestingInventory.Remove(userID); + lock (m_RequestTime) + { + if (m_RequestTime.ContainsKey(userID)) + { + m_RequestTime.Remove(userID); + } + } } else { -- cgit v1.1