From ce234eee376d5af3506399c22519b21ad7540431 Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Sat, 31 May 2008 20:01:09 +0000
Subject: * Made UpdateUserCurrentRegion a bit more forgiving.

---
 .../Region/Communications/OGS1/OGS1UserServices.cs | 44 +++++++++++++++++-----
 1 file changed, 35 insertions(+), 9 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index e0e17df..17b5a06 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -205,25 +205,51 @@ namespace OpenSim.Region.Communications.OGS1
             IList parameters = new ArrayList();
             parameters.Add(param);
             XmlRpcRequest req = new XmlRpcRequest("update_user_current_region", parameters);
-            XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
-            Hashtable respData = (Hashtable)resp.Value;
-            if (respData.ContainsKey("returnString"))
+
+            XmlRpcResponse resp;
+            
+            try
             {
-                if ((string)respData["returnString"] == "TRUE")
+                resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
+            }
+            catch(WebException)
+            {
+                m_log.Warn("[OSG1 USER SERVICES]: Grid not responding. Retrying.");
+
+                try
                 {
-                    m_log.Info("[OSG1 USER SERVICES]: Successfully updated user record");
+                    resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
                 }
-                else
+                catch (WebException)
                 {
-                    m_log.Error("[OSG1 USER SERVICES]: Error updating user record");
+                    m_log.Warn("[OSG1 USER SERVICES]: Grid not responding. Failed.");
+                    return;
                 }
             }
-            else
+           
+            if( resp == null )
             {
-                m_log.Warn("[OSG1 USER SERVICES]: Error updating user record, Grid server may not be updated.");
+                m_log.Warn("[OSG1 USER SERVICES]: Got no response, Grid server may not be updated.");
+                return;
             }
 
+            Hashtable respData = (Hashtable)resp.Value;
 
+            if (respData == null || !respData.ContainsKey("returnString"))
+            {
+                m_log.Warn("[OSG1 USER SERVICES]: Error updating user record, Grid server may not be updated.");
+            }
+            else
+            {
+                if ((string) respData["returnString"] == "TRUE")
+                {
+                    m_log.Info("[OSG1 USER SERVICES]: Successfully updated user record");
+                }
+                else
+                {
+                    m_log.Error("[OSG1 USER SERVICES]: Error updating user record");
+                }
+            }
         }
 
         public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
-- 
cgit v1.1