Closing more streams even if things fail.

prioritization
Diva Canto 2009-10-04 10:12:19 -07:00
parent fe9cca64de
commit 30aac00f6b
1 changed files with 25 additions and 6 deletions

View File

@ -106,7 +106,6 @@ namespace OpenSim.Framework.Communications.Clients
AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
os = AgentCreateRequest.GetRequestStream(); os = AgentCreateRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
//m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri);
} }
//catch (WebException ex) //catch (WebException ex)
@ -116,6 +115,11 @@ namespace OpenSim.Framework.Communications.Clients
reason = "cannot contact remote region"; reason = "cannot contact remote region";
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@ -224,7 +228,6 @@ namespace OpenSim.Framework.Communications.Clients
ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send
os = ChildUpdateRequest.GetRequestStream(); os = ChildUpdateRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
//m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
} }
//catch (WebException ex) //catch (WebException ex)
@ -234,6 +237,11 @@ namespace OpenSim.Framework.Communications.Clients
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate");
@ -437,7 +445,6 @@ namespace OpenSim.Framework.Communications.Clients
ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
os = ObjectCreateRequest.GetRequestStream(); os = ObjectCreateRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
} }
//catch (WebException ex) //catch (WebException ex)
@ -447,6 +454,11 @@ namespace OpenSim.Framework.Communications.Clients
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@ -512,7 +524,6 @@ namespace OpenSim.Framework.Communications.Clients
ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
os = ObjectCreateRequest.GetRequestStream(); os = ObjectCreateRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
//m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri);
} }
//catch (WebException ex) //catch (WebException ex)
@ -522,6 +533,11 @@ namespace OpenSim.Framework.Communications.Clients
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@ -597,7 +613,6 @@ namespace OpenSim.Framework.Communications.Clients
HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send
os = HelloNeighbourRequest.GetRequestStream(); os = HelloNeighbourRequest.GetRequestStream();
os.Write(buffer, 0, strBuffer.Length); //Send it os.Write(buffer, 0, strBuffer.Length); //Send it
os.Close();
//m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
} }
//catch (WebException ex) //catch (WebException ex)
@ -607,7 +622,11 @@ namespace OpenSim.Framework.Communications.Clients
return false; return false;
} }
finally
{
if (os != null)
os.Close();
}
// Let's wait for the response // Let's wait for the response
//m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");