aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Hypergrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs14
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs69
2 files changed, 41 insertions, 42 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
index 5c50936..5004d99 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
@@ -73,7 +73,6 @@ namespace OpenSim.Services.Connectors
73 } 73 }
74 } 74 }
75 75
76
77 public virtual string Helo() 76 public virtual string Helo()
78 { 77 {
79 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); 78 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
@@ -82,10 +81,12 @@ namespace OpenSim.Services.Connectors
82 81
83 try 82 try
84 { 83 {
85 WebResponse response = req.GetResponse(); 84 using (WebResponse response = req.GetResponse())
86 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null 85 {
87 return string.Empty; 86 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
88 return response.Headers.Get("X-Handlers-Provided"); 87 return string.Empty;
88 return response.Headers.Get("X-Handlers-Provided");
89 }
89 } 90 }
90 catch (Exception e) 91 catch (Exception e)
91 { 92 {
@@ -95,6 +96,5 @@ namespace OpenSim.Services.Connectors
95 // fail 96 // fail
96 return string.Empty; 97 return string.Empty;
97 } 98 }
98
99 } 99 }
100} 100} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2f263ae..47d0cce 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -171,41 +171,45 @@ namespace OpenSim.Services.Connectors.Hypergrid
171 // Let's wait for the response 171 // Let's wait for the response
172 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); 172 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
173 173
174 WebResponse webResponse = null;
175 StreamReader sr = null;
176 try 174 try
177 { 175 {
178 webResponse = AgentCreateRequest.GetResponse(); 176 using (WebResponse webResponse = AgentCreateRequest.GetResponse())
179 if (webResponse == null)
180 { 177 {
181 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); 178 if (webResponse == null)
182 }
183 else
184 {
185
186 sr = new StreamReader(webResponse.GetResponseStream());
187 string response = sr.ReadToEnd().Trim();
188 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
189
190 if (!String.IsNullOrEmpty(response))
191 { 179 {
192 try 180 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
193 { 181 }
194 // we assume we got an OSDMap back 182 else
195 OSDMap r = Util.GetOSDMap(response); 183 {
196 bool success = r["success"].AsBoolean(); 184 using (Stream s = webResponse.GetResponseStream())
197 reason = r["reason"].AsString();
198 return success;
199 }
200 catch (NullReferenceException e)
201 { 185 {
202 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); 186 using (StreamReader sr = new StreamReader(s))
203 187 {
204 // check for old style response 188 string response = sr.ReadToEnd().Trim();
205 if (response.ToLower().StartsWith("true")) 189 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
206 return true; 190
207 191 if (!String.IsNullOrEmpty(response))
208 return false; 192 {
193 try
194 {
195 // we assume we got an OSDMap back
196 OSDMap r = Util.GetOSDMap(response);
197 bool success = r["success"].AsBoolean();
198 reason = r["reason"].AsString();
199 return success;
200 }
201 catch (NullReferenceException e)
202 {
203 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
204
205 // check for old style response
206 if (response.ToLower().StartsWith("true"))
207 return true;
208
209 return false;
210 }
211 }
212 }
209 } 213 }
210 } 214 }
211 } 215 }
@@ -216,11 +220,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
216 reason = "Destination did not reply"; 220 reason = "Destination did not reply";
217 return false; 221 return false;
218 } 222 }
219 finally
220 {
221 if (sr != null)
222 sr.Close();
223 }
224 223
225 return true; 224 return true;
226 225