mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already.
This commit is contained in:
@@ -171,41 +171,45 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
// Let's wait for the response
|
||||
//m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
|
||||
|
||||
WebResponse webResponse = null;
|
||||
StreamReader sr = null;
|
||||
try
|
||||
{
|
||||
webResponse = AgentCreateRequest.GetResponse();
|
||||
if (webResponse == null)
|
||||
using (WebResponse webResponse = AgentCreateRequest.GetResponse())
|
||||
{
|
||||
m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
sr = new StreamReader(webResponse.GetResponseStream());
|
||||
string response = sr.ReadToEnd().Trim();
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
|
||||
|
||||
if (!String.IsNullOrEmpty(response))
|
||||
if (webResponse == null)
|
||||
{
|
||||
try
|
||||
m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Stream s = webResponse.GetResponseStream())
|
||||
{
|
||||
// we assume we got an OSDMap back
|
||||
OSDMap r = Util.GetOSDMap(response);
|
||||
bool success = r["success"].AsBoolean();
|
||||
reason = r["reason"].AsString();
|
||||
return success;
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
|
||||
using (StreamReader sr = new StreamReader(s))
|
||||
{
|
||||
string response = sr.ReadToEnd().Trim();
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
|
||||
|
||||
// check for old style response
|
||||
if (response.ToLower().StartsWith("true"))
|
||||
return true;
|
||||
if (!String.IsNullOrEmpty(response))
|
||||
{
|
||||
try
|
||||
{
|
||||
// we assume we got an OSDMap back
|
||||
OSDMap r = Util.GetOSDMap(response);
|
||||
bool success = r["success"].AsBoolean();
|
||||
reason = r["reason"].AsString();
|
||||
return success;
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
|
||||
|
||||
return false;
|
||||
// check for old style response
|
||||
if (response.ToLower().StartsWith("true"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,11 +220,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||
reason = "Destination did not reply";
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (sr != null)
|
||||
sr.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user